public IMyClass GetMyClass()
    {
        var c1 = new myClass();
        var c2 = c1.GetMyClass();

        return(c2);
    }
Пример #2
0
 protected void btnSub_Click(object sender, EventArgs e)
 {
     if (txtID.Text.Length == 0 || txtID.Text.Length >= 12)
     {
         Response.Write("<script>alert('请合法输入!')</script>");
     }
     else
     {
         int       id      = Convert.ToInt32(txtID.Text);
         string    sql     = "select * from UserList where id = '" + id + "'";
         myClass   myclass = new myClass();
         DataTable dt      = new DataTable();
         dt = myclass.JudgeIor(sql);
         string email   = dt.Rows[0][7].ToString();
         string Massage = "*****@*****.**";
         Int16  x       = 1000;
         Random Random  = new System.Random();
         string rad     = Convert.ToString(Random.Next(x, x * 10));
         string massage = "您的随机验证码是" + rad + ",收到后请将验证码输于找回页面。";
         bool   flag    = Sendemails(Massage, email, "找回密码", massage);
         if (flag)
         {
             Response.Write("<script>alert('发送成功!');location='Test.aspx'</script>");
             Session["rad"] = rad;
             Session["id"]  = Convert.ToString(id);
         }
     }
 }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["id"] == null)
        {
            Response.Write("<script>alert('请先登录!');location='../Login.aspx'</script>");
        }
        else
        {
            if (!IsPostBack)
            {
                int id = Convert.ToInt32(Session["id"].ToString());

                string sql = "select * from LogClass where logowner = '" + id + "'";

                myClass myclass = new myClass();

                DataTable dt = new DataTable();

                dt = myclass.JudgeIor(sql);

                rptClass.DataSource = dt;

                rptClass.DataBind();
            }
        }
    }
Пример #4
0
    public static myClass CreateAnObject(string s)
    {
        myClass _mc = new myClass();

        _mc.myString = s;
        return(_mc);
    }
Пример #5
0
        static void Main(string[] args)
        {
            Person Rita = new Person {
                Name = "Rita", age = 26
            };

            Console.WriteLine(Rita.age);
            Console.WriteLine(IsAdult(baseAge: 18, age: 26));

            // Static Method in myClass

            for (int i = 0; i < 10; i++)
            {
                myClass my = myClass.Factory(i, i * 2);
                my.Show();
            }

            // Static Class

            Console.WriteLine(Numeric.Num(34.88));
            Console.WriteLine(Numeric.Part(34.88));
            Console.WriteLine(Numeric.IsEven(34.88));
            Console.WriteLine(Numeric.IsOdd(34.88));


            Console.ReadKey();
        }
 void myOutFunction(out myClass outObj)
 {
     outObj = new myClass {
         Name = "out inside function <br/>"
     };
     Response.Write(outObj.Name);     //out inside function
 }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int id;

        if (Session["id"] == null)
        {
            Response.Write("<script>alert('请先登录!');location='../Login.aspx'</script>");
        }
        else
        {
            if (Session["Friendid"] != null)
            {
                id            = Convert.ToInt32(Session["Friendid"].ToString());
                divMe.Visible = false;
                divFr.Visible = true;
            }
            else
            {
                id = Convert.ToInt32(Session["id"].ToString());
            }
            if (!IsPostBack)
            {
                myClass myclass = new myClass();


                string sql = "select * from UserList where id = '" + id + "'";

                DataTable dt = new DataTable();

                dt            = myclass.JudgeIor(sql);
                scup.ImageUrl = dt.Rows[0][6].ToString();
                lbName.Text   = dt.Rows[0][1].ToString();
            }
        }
    }
Пример #8
0
    protected void btnSub_Click(object sender, EventArgs e)
    {
        myClass myclass = new myClass();

        int      id    = Convert.ToInt32(Session["id"].ToString());
        string   state = txtState.Text;
        DateTime now   = DateTime.Now;

        //判断空值
        if (state.Length == 0)
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            //发表说说
            string name      = myclass.RerdName(id);
            string sculpture = myclass.RerdSculpture(id);
            string sql       = "insert into State (stater,statetime,statement,statelike,statername,staterscu) values('" + id + "','" + now + "','" + state + "',',','" + name + "','" + sculpture + "')";
            int    flag      = myclass.DataSQL(sql);
            if (flag == 1)
            {
                Response.Write("<script>alert('发布成功!');location='Myhistory.aspx'</script>");
            }
        }
    }
Пример #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string id = Session["id"].ToString();


        string hobby = Session["hobby"].ToString();

        string sql1 = "select * from UserList where hobby ='" + hobby + "' and id <> '" + id + "'";

        myClass myclass = new myClass();

        DataTable dt = new DataTable();

        dt = myclass.JudgeIor(sql1);

        rptsomeFriend.DataSource = dt;

        rptsomeFriend.DataBind();

        string sql2 = "select * from UserList where id <> '" + id + "'";

        dt = myclass.JudgeIor(sql2);

        rptallFriend.DataSource = dt;

        rptallFriend.DataBind();

        if (!IsPostBack)
        {
            divSome.Visible = true;
            divAll.Visible  = false;
        }
    }
Пример #10
0
    public void MyFunction()
    {
        myClass myClassInstance = new myClass();

        // working with myClassInstance
        _list.Add(myClassInstance);
    }
Пример #11
0
    protected void btnSub_Click(object sender, EventArgs e)
    {
        myClass myclass = new myClass();

        int id = Convert.ToInt32(Session["id"].ToString());

        string name      = txtName.Text;
        string authority = rdlAuthority.SelectedValue;

        if (name.Length == 0)
        {
            Response.Write("<script>alert('名称不能为空!')</script>");
        }
        else
        {
            string interfaces = "picture/QQ截图20161126121705.png";
            string sql        = "insert into Album (albumname,interface,owner,authority) values('" + name + "','" + interfaces + "','" + id + "','" + authority + "')";
            int    flag       = myclass.DataSQL(sql);
            if (flag == 1)
            {
                Response.Write("<script>alert('添加成功!');location='Album.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败!');location='AddAlbum.aspx'</script>");
            }
        }
    }
Пример #12
0
        public object UploadCustomerImage(int customerId, [FromBody] myClass model)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);
            Bitmap          qrCodeImage = qrCode.GetGraphic(20);

            MemoryStream oMStream = new MemoryStream();

            qrCodeImage.Save(oMStream, System.Drawing.Imaging.ImageFormat.Png);

            byte[] byteImage = oMStream.ToArray();


            //Depending on if you want the byte array or a memory stream, you can use the below.
            //THIS IS NO LONGER NEEDED AS OUR MODEL NOW HAS A BYTE ARRAY
            //var imageDataByteArray = Convert.FromBase64String(model.ImageData);

            //When creating a stream, you need to reset the position, without it you will see that you always write files with a 0 byte length.

            //Go and do something with the actual data.
            //_customerImageService.Upload([...])

            //For the purpose of the demo, we return a file so we can ensure it was uploaded correctly.
            //But otherwise you can just return a 204 etc.
            return(new { val = Convert.ToBase64String(byteImage) });//File(model.ImageData, "image/png");
        }
Пример #13
0
 public MyViewModel()
 {
     collection = new ObservableCollection <myClass>(new[]
     {
         new myClass {
             text = "some more test - some more test - some more test - some more test - some more test - some more test - some more test - some more test - some more test - "
         },
         new myClass {
             text = "test me test me = test me test me = test me test me = test me test me = test me test me = test me test me = "
         },
         new myClass {
             text = "test again - test again - test again - test again - test again - "
         },
         new myClass {
             text = "test again - test again - "
         },
         new myClass {
             text = "test again - "
         },
         new myClass {
             text = "test"
         },
     });
     mc = new myClass();
 }
Пример #14
0
        static void Main(string[] args)
        {
            myClass <string, string> myClass = new myClass <string, string>();

            myClass.MyProperty  = "A String value";
            myClass.MyProperty2 = "Another string value";

            myClass <int, string> myClass2 = new myClass <int, string>();

            myClass2.MyProperty  = 1;
            myClass2.MyProperty2 = "A string value";

            myClass <int, int> myClass3 = new myClass <int, int>();

            myClass3.MyProperty  = 1;
            myClass3.MyProperty2 = 2583;

            myClass <bool, ChocolateCake> myClass4 = new myClass <bool, ChocolateCake>();

            myClass4.MyProperty         = true;
            myClass4.MyProperty2        = new ChocolateCake();
            myClass4.MyProperty2.Flavor = "Chocolate";



            foreach (var item in newList)
            {
                Console.WriteLine("My cake is a type" + item.flavor
                                  + "And the flavor is" + item.type);
            }
        }
Пример #15
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: The first argument is a null reference");

        try
        {
            // a non-null object
            object value = new myClass(-100);
            // a null object
            object comparand = null;
            // a null initial state
            globalValue = null;
            // globalValue is null, so it should switch
            // and return null
            // this is a major difference with
            // InterlockedCompareExchange8.cs --
            // here we use the object overload
            state = Interlocked.CompareExchange(ref globalValue, value, comparand);
            // globalValue should equal value now
            if (globalValue != value)
            {
                TestLibrary.TestFramework.LogError("005", "The method did not works, the result is" + globalValue + " " + state);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Пример #16
0
 static void Main(string[] args)
 {
     // here you call the single instance of myClass
     myClass myClassInstance = myClass.Instance;
     // run the public someothermethod of myClass
     myClassInstance.SomeOtherMethod();
 }
Пример #17
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: The object is a custom class");

        obMyClass = new myClass(123456789);
        try
        {
            // Spin up two new threads
            threadA = new Thread(new ThreadStart(TestComChange2));
            threadB = new Thread(new ThreadStart(changeGlobal2));
            // Start Thread A
            // Thread A runs TestComChange2
            threadA.Start();
            // Block spawning thread until Thread A completes
            threadA.Join();
            // now, the final values of
            // globalValue and state should NOT be -100
            if (((myClass)globalValue).a != -100 && ((myClass)state).a != -100)
            {
                TestLibrary.TestFramework.LogError("003", "The method did not works, the result is" + globalValue + " " + state);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Пример #18
0
    public void TestComChange2()
    {
        // set a value
        object value = new myClass(-100);
        // set a different value
        object comparand = obMyClass;
        int    i         = 0;

        // loop 20 times
        while (i < 20)
        {
            // first ten times, we just skip this
            // then on the tenth time, fire Thread B,
            // setting globalValue to obMyClass
            if (i == 10)
            {
                threadB.Start();
                threadB.Join();
            }
            // first ten iterations, globalValue does not
            // equal comparand, so it keeps returning
            // the contents of globalValue without
            // poking value into it
            // after ten, Thread B kicks in, and
            // it matches, subsequently, globalValue
            // gets set to point to where value does
            // this is a major difference with
            // InterlockedCompareExchange8.cs --
            // here we use the object overload
            state = Interlocked.CompareExchange(ref globalValue, value, comparand);
            i++;
        }
    }
Пример #19
0
    protected void btnSub_Click(object sender, EventArgs e)
    {
        int    id        = Convert.ToInt16(Session["id"].ToString());
        string classname = txtAdd.Text;

        if (classname.Length == 0)
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            string sql = "insert into LogClass (logowner,classfyname) values('" + id + "','" + classname + "')";

            myClass myclass = new myClass();

            int flag = myclass.DataSQL(sql);

            if (flag == 1)
            {
                Response.Write("<script>alert('添加成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败!')</script>");
            }
            Server.Transfer("Abstract.aspx");
        }
    }
Пример #20
0
    protected void rptClassfy_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        if (e.CommandName == "Delete")
        {
            int classfyid = Convert.ToInt32(e.CommandArgument.ToString());

            string sql = "select * from LogClass where classfyid = '" + classfyid + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);

            string campare = "默认分类";

            if (string.Compare(campare, dt.Rows[0][1].ToString()) == 0)
            {
                Response.Write("<script>alert('默认分类不能删除!')</script>");
            }
            else
            {
                sql = "delete from LogClass where classfyid='" + classfyid + "'";

                int flag = myclass.DataSQL(sql);

                if (flag == 1)
                {
                    Response.Write("<script>alert('删除成功!')</script>");
                    Server.Transfer("Abstract.aspx");
                }
            }
        }
    }
Пример #21
0
    static void Main()
    {
        // objects
        myClass obj1 = new myClass();

        obj1.setFields();
        myClass obj2 = new myClass();

        obj2.setFields(7.1f, 4.3f);
        myClass obj3 = new myClass();

        obj3.setFields(26.1f, 7.6f, 14.5f);
        // squares of sums
        float sumSquared1 = obj1.myMethod();
        float sumSquared2 = obj2.myMethod();
        float sumSquared3 = obj3.myMethod();
        // object with the biggest square of its members' sum
        string biggestObj = (sumSquared3 > sumSquared2 && sumSquared3 > sumSquared1) ? "obj3" : (sumSquared2 > sumSquared1 ? "obj2" : "obj1");

        // print
        Console.WriteLine($"obj1: square of its members sum - {sumSquared1}");
        Console.WriteLine($"obj2: square of its members sum - {sumSquared2}");
        Console.WriteLine($"obj3: square of its members sum - {sumSquared3}");
        Console.WriteLine($"object with the biggest square of its members' sum is {biggestObj}");
    }
Пример #22
0
    protected void rptDraft_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        //发布日志
        if (e.CommandName == "Submit")
        {
            int       logid = Convert.ToInt32(e.CommandArgument.ToString());
            int       id    = Convert.ToInt32(Session["id"].ToString());
            DataTable dt    = new DataTable();
            string    sql   = "select * from Log where logid ='" + logid + "'";
            dt = myclass.JudgeIor(sql);
            string   title    = dt.Rows[0][1].ToString();
            string   simplify = dt.Rows[0][8].ToString();
            DateTime now      = DateTime.Now;
            //判断分类决定是否要同步动态到个人中心
            sql = "select * from Log where logid = '" + logid + "'";
            dt  = myclass.JudgeIor(sql);
            string compare = "所有人可见";
            if (string.Compare(compare, dt.Rows[0][5].ToString()) == 0)
            {
                sql = "update Log set draft = '1',logtime='" + now + "' where logid='" + logid + "'";
                int    flag      = myclass.DataSQL(sql);
                string name      = myclass.RerdName(id);
                string sculpture = myclass.RerdSculpture(id);
                string other     = name + "发表了日志" + title;
                string state     = "insert into State (stater,statetime,other,statelike,statername,staterscu,logs,lable) values('" + id + "','" + now + "','" + other + "',',','" + name + "','" + sculpture + "','" + logid + "','" + simplify + "')";
                int    stateflag = myclass.DataSQL(state);
            }

            Response.Write("<script>alert('发布成功!')</script>");
            Server.Transfer("Log.aspx");
        }
    }
Пример #23
0
    protected void btnChange_Click(object sender, EventArgs e)
    {
        string pwd   = txtPwd.Text;
        string repwd = txtrePwd.Text;

        if (String.Compare(pwd, repwd) != 0)
        {
            Response.Write("<script>alert('前后两次密码不一样!')</script>");
        }
        else
        {
            int id = Convert.ToInt32(Session["id"].ToString());

            pwd = MD5(pwd);

            string sql = "update UserList set pwd='" + pwd + "' where id='" + id + "'";

            myClass myclass = new myClass();

            int flag = myclass.DataSQL(sql);

            if (flag == 1)
            {
                Response.Write("<script>alert('重置成功!');location='Login.aspx'</script>");
            }
        }
    }
Пример #24
0
    //好友内层repeater绑定
    protected void rptFr_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        myClass myclass = new myClass();

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView drvw = (DataRowView)e.Item.DataItem;

            int ID = Convert.ToInt32(drvw["replyid"]);

            string replyclass = "photo";

            string sql = "select * from ReplyComment where _thereplyid=" + ID + " and _replyclass = '" + replyclass + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);

            Repeater rept = (Repeater)e.Item.FindControl("rptFrC");

            rept.DataSource = dt;

            rept.DataBind();
        }
    }
Пример #25
0
        static void Main(string[] args)
        {
            myClass test = new myClass(3, 4);

            test.Method();
            Console.ReadKey();
        }
Пример #26
0
    //用户内层repeater
    protected void rptComment_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        if (e.CommandName == "Delete")
        {
            int massagecommentid = Convert.ToInt32(e.CommandArgument.ToString());

            string sql = "delete from MassageComment where massagecommentid='" + massagecommentid + "'";

            int flag = myclass.DataSQL(sql);

            if (flag == 1)
            {
                Response.Write("<script>alert('删除成功!')</script>");
            }
            Server.Transfer("Message.aspx");
        }
        if (e.CommandName == "Jump1")
        {
            int friendid = Convert.ToInt32(e.CommandArgument.ToString());
            Session["Friendid"] = friendid.ToString();
            Response.Write("<script>window.location='../Person/Person.aspx'</script>");
        }
        if (e.CommandName == "Jump2")
        {
            int friendid = Convert.ToInt32(e.CommandArgument.ToString());
            Session["Friendid"] = friendid.ToString();
            Response.Write("<script>window.location='../Person/Person.aspx'</script>");
        }
    }
Пример #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["id"] == null)
        {
            Response.Write("<script>alert('请先登录!');location='../Login.aspx'</script>");
        }
        else

        {
            int id = Convert.ToInt32(Session["id"].ToString());

            myClass myclass = new myClass();

            DataTable dt = new DataTable();

            string sql;

            sql = "select * from Visitor where bevisitor='" + id + "' and visitor <> '" + id + "'";

            dt = myclass.JudgeIor(sql);

            rptHistory.DataSource = dt;

            rptHistory.DataBind();

            lbCountAll.Text = "历史访问量:" + Convert.ToString(dt.Rows.Count);
        }
    }
Пример #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //验证登陆
        if (Session["id"] == null)
        {
            Response.Write("<script>alert('请先登录!');location='../Login.aspx'</script>");
        }
        else
        {
            myClass myclass = new myClass();
            int     id      = Convert.ToInt32(Session["id"].ToString());

            scup.ImageUrl = "../" + myclass.RerdSculpture(id);
            lbName.Text   = myclass.RerdName(id);

            string sql = "select * from LogClass where logowner='" + id + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);
            //动态绑定下拉框
            dropClass.DataSource = dt;

            dropClass.DataTextField = "classfyname";

            dropClass.DataBind();
        }
    }
Пример #29
0
    protected void lbtForrow_Click(object sender, EventArgs e)
    {
        int id;

        if (Session["Friendid"] != null)
        {
            id = Convert.ToInt32(Session["Friendid"].ToString());
        }
        else
        {
            id = Convert.ToInt32(Session["id"].ToString());
        }
        int logid = Convert.ToInt32(Request.QueryString["logid"]);

        string sql = "select top 1 * from Log where author = '" + id + "' and draft = '0' and logid>'" + logid + "' order by logid ASC";



        DataTable dt      = new DataTable();
        myClass   myclass = new myClass();

        dt = myclass.JudgeIor(sql);

        lbtForrow.PostBackUrl = "LogContent.aspx?logid=" + dt.Rows[0][0].ToString();
        //Response.Redirect('LogContent.aspx');

        Response.Write("<script>window.location='LogContent.aspx'</script>");
    }
Пример #30
0
    protected void rptComment_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        //跳页
        if (e.CommandName == "Jump1")
        {
            int friendid = Convert.ToInt32(e.CommandArgument.ToString());
            Session["Friendid"] = friendid.ToString();
            Response.Write("<script>window.location='Person/Person.aspx'</script>");
        }

        if (e.CommandName == "Jump2")
        {
            int friendid = Convert.ToInt32(e.CommandArgument.ToString());
            Session["Friendid"] = friendid.ToString();
            //Server.Transfer("Person/Person.asxp");
            Response.Write("<script>window.location='Myhistory.aspx'</script>");
        }
        //删除评论
        if (e.CommandName == "Delete")
        {
            int statecommentid = Convert.ToInt32(e.CommandArgument.ToString());

            string sql = "select * from StateComment where statecommentid = '" + statecommentid + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);

            string time = dt.Rows[0][3].ToString();

            //同步删除照片评论
            if (dt.Rows[0][6].ToString().Length == 0)
            {
                int    classid = Convert.ToInt32(dt.Rows[0][7].ToString());
                string classfy = "photo";
                sql = "delete from Reply where replytime='" + time + "' and classid ='" + classid + "' and replyclass = '" + classfy + "' ";
                myclass.DataSQL(sql);
            }
            //同步删除日志评论
            else
            {
                int    classid = Convert.ToInt32(dt.Rows[0][6].ToString());
                string classfy = "log";
                sql = "delete from Reply where replytime='" + time + "' and classid ='" + classid + "' and replyclass = '" + classfy + "' ";
                myclass.DataSQL(sql);
            }
            //删除评论
            sql = "delete from StateComment where statecommentid='" + statecommentid + "'";

            int flag = myclass.DataSQL(sql);

            if (flag == 1)
            {
                Response.Write("<script>alert('删除成功!');location='Myhistory.aspx'</script>");
            }
        }
    }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the Dispose method in Dictionary Enumerator 2");
     try
     {
         myClass TKey = new myClass();
         myClass TValue = new myClass();
         Dictionary<myClass, myClass> dic = new Dictionary<myClass, myClass>();
         dic.Add(TKey,TValue );
         Dictionary<myClass, myClass>.Enumerator enumer1 = new Dictionary<myClass, myClass>.Enumerator();
         Dictionary<myClass, myClass>.Enumerator enumer2 = dic.GetEnumerator();
         enumer2.Dispose();
         enumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Пример #32
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: The object is a custom class");

        obMyClass = new myClass(123456789);
        try
        {
            // Spin up two new threads
            threadA = new Thread(new ThreadStart(TestComChange2));
            threadB = new Thread(new ThreadStart(changeGlobal2));
            // Start Thread A
            // Thread A runs TestComChange2
            threadA.Start();
            // Block spawning thread until Thread A completes
            threadA.Join();
            // Once Thread A completes, block spawning thread 
            // until Thread B completes as well
            threadB.Join();
            // now, the final values of
            // globalValue and state should NOT be -100
            if (((myClass)globalValue).a != -100 && ((myClass)state).a != -100)
            {
                TestLibrary.TestFramework.LogError("003", "The method did not works, the result is" + globalValue + " " + state);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Пример #33
0
 public static myClass CreateAnObject(string s)
 {
     myClass _mc = new myClass();
     _mc.myString = s;
     return _mc;
 }
Пример #34
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: The first argument is a null reference");

        try
        {
            // a non-null object
            object value = new myClass(-100);
            // a null object
            object comparand = null;
            // a null initial state
            globalValue = null;
            // globalValue is null, so it should switch
            // and return null
            // this is a major difference with
            // InterlockedCompareExchange8.cs --
            // here we use the object overload
            state = Interlocked.CompareExchange(ref globalValue, value, comparand);
            // globalValue should equal value now
            if (globalValue != value)
            {
                TestLibrary.TestFramework.LogError("005", "The method did not works, the result is" + globalValue + " " + state);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Пример #35
0
 public void TestComChange2()
 {
     // set a value
     object value = new myClass(-100);
     // set a different value
     object comparand = obMyClass;
     int i = 0;
     // loop 20 times
     while (i < 20)
     {
         // first ten times, we just skip this
         // then on the tenth time, fire Thread B,
         // setting globalValue to obMyClass
         if (i == 10)
         {
             threadB.Start();
         }
         // first ten iterations, globalValue does not
         // equal comparand, so it keeps returning 
         // the contents of globalValue without
         // poking value into it
         // after ten, Thread B kicks in, and
         // it matches, subsequently, globalValue
         // gets set to point to where value does
         // this is a major difference with
         // InterlockedCompareExchange8.cs --
         // here we use the object overload
         state = Interlocked.CompareExchange(ref globalValue, value, comparand);
         i++;
         Thread.Sleep(10);
     }
 }
Пример #36
0
        private void btnRunExcel_Click(object sender, EventArgs e)
        {
            try
            {
                myClass myclass = new myClass();
                List<FPExcelOutPut> LayOutExcel = new List<FPExcelOutPut>();
                foreach (string DbName in this.listBoxDBF.Items)
                {
                    myclass.runFPExcel(DbName,  toolStripProgressBar1, toolStripLabel1,ref LayOutExcel);
                }

                APP_Code.ExportToExcel exportToExcel = new APP_Code.ExportToExcel();

                //string tmp = Path.GetDirectoryName(txtDatName.Text);

                string tmpFileExcelName = "Prueba";

                if (File.Exists(_excelPahtOut + "\\FP" + tmpFileExcelName + ".xlsx"))
                    File.Delete(_excelPahtOut + "\\FP" + tmpFileExcelName + ".xlsx");

                FileInfo excelTargetFile = new FileInfo(_excelPahtOut + "\\FP" + tmpFileExcelName + ".xlsx");
                exportToExcel.MyExportToExcel(LayOutExcel, excelTargetFile);
                exportToExcel = null;

                MessageBox.Show("Done");

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #37
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            myClass myclass = new myClass();
            try
            {
                //myclass.company = RBMMM.Checked ? "MMM" : "PMC";
                myclass.is1500 = RB1500.Checked ? true : false;
                toolStripProgressBar1.Value = 0;
                this.Enabled = false;

                if (RBFP.Checked)
                {//is FP
                    if (myclass.runFP(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiff(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "v1pagina", "99");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (RBMMM.Checked)
                {//IS MMM
                    myclass.company = "MMM";
                    if (myclass.run(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiff(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "0000");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    }
                }
                else if (RBPMC.Checked)
                {// IS PMC
                    myclass.company = "PMC";
                    if (myclass.run(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiff(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "0000");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                } else if (rdbPSGMMM.Checked)
                {//psgmmm
                    myclass.company = "PSGMMM";
                    if (myclass.runPSG(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1,"00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiffPSG(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                }
                else if (rdbPSGPMC.Checked)
                {//psgpmc
                    myclass.company = "PSGPMC";
                    if (myclass.runPSG(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1,"00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiffPSG(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (rdbPSGMMM_OnGoing.Checked)
                {
                    myclass.company = "PSGMMM";

                    if (myclass.runPSG_ONGOING(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1,"00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiff(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (rdbPSGPMC_OnGoing.Checked)
                {
                    myclass.company = "PSGPMC";
                    if (myclass.runPSG_ONGOING(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1,"00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiff(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                else if (rdbPSGPMC_OnGoing_NO_CLM.Checked)
                {
                    myclass.company = "PSGPMC";
                    if (myclass.runPSG_ONGOING_NO_CLM(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1, "00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiff(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                else if (rdbPSGMMM_OnGoing_NO_CLM.Checked)
                {
                    myclass.company = "PSGMMM";
                    if (myclass.runPSG_ONGOING_NO_CLM(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1, "00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiff(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                else if (RDBPSGMMMIDX.Checked)
                {
                    myclass.company = "PSGMMM";
                    if (myclass.runPSGIDX(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1, "00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiffPSGIDX(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (RDBPSGPMCIDX.Checked)
                {
                    myclass.company = "PSGPMC";
                    if (myclass.runPSGIDX(txtDbNAme.Text, txtDatName.Text, txtLineaServ.Text.Trim(), toolStripProgressBar1, toolStripLabel1, "00"))
                    {
                        toolStripProgressBar1.Value = 0;
                        if (chkStaping.Checked)
                        {
                            myclass.multiTiffPSGIDX(txtIn.Text, txtImgDes.Text, txtDbNAme.Text, toolStripProgressBar1, toolStripLabel1, "V1CROSSREF", "00");
                            MessageBox.Show("Total de Imagenes:" + myclass._totalmg, "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        MessageBox.Show("Total de Reclamaciones:" + myclass._totalReclamaciones + "\r\n" +
                                        "Total de Imagenes:" + myclass._totalmg + "\r\n" +
                                        "Total de CrossRef:" + myclass._TotalCrossRef
                            , "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    throw new Exception("Error con la compañia");
                }

                MessageBox.Show("Done...", "ImageData, Inc.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                myclass = null;
                this.Enabled = true;
            }
        }
Пример #38
0
            public static int Main_old()
            {
                myClass[] arr = new myClass[10];

                return 0;
            }