Пример #1
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     if (dxValidationProvider1.Validate())
     {
         NewEntity ne = new NewEntity();
         ne.Id_Location   = Guid.Empty;
         ne.Id_EntityType = (Guid)lue_locationType.EditValue;
         ne.Id_City       = (Guid)lue_City.EditValue;
         ne.Latitude      = (float)Convert.ToDecimal(edt_Lat.Text.ToString().Trim());
         ne.Longitude     = (float)Convert.ToDecimal(edt_Lon.Text.ToString().Trim());
         ne.description   = edt_Description.Text;
         ne.coords        = ne.Latitude.ToString("0.000000") + "°, " + ne.Longitude.ToString("0.000000") + "°";
         ne.URL           = edt_URL.Text;
         ne.address       = edt_address.Text;
         ne.ZIPcode       = edt_zip.Text;
         ne.Status        = true;
         SQLCon.SQLCon con = new SQLCon.SQLCon();
         toastNotificationsManager1.Notifications[0].Body =
             con.sendNewEntity(ne).Rows[0].ItemArray[1].ToString();
         toastNotificationsManager1.Notifications[0].Header = "";
         toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[0]);
         lue_locationType.EditValue = null;
         lue_City.EditValue         = null;
         lue_state.EditValue        = null;
         edt_Description.EditValue  = null;
         edt_zip.EditValue          = null;
         edt_address.EditValue      = null;
         edt_Lat.EditValue          = edt_Lon.EditValue = null;
         edt_URL.EditValue          = null;
     }
 }
Пример #2
0
    public void Hunt()
    {
        // Looking for a prey in sight
        List <NewEntity> nearPreys = CheckForPreys();

        if (nearPreys.Capacity == 0)
        {
            // If no prey in sight, continue moving randomly
            Move();
        }
        else
        {
            // Prey found ! Chasing.
            NewEntity prey         = ChoosePrey(nearPreys);
            Vector3   preyPosition = prey.transform.position;
            Vector3   distance     = preyPosition - transform.position;
            if (distance.magnitude < _size + (prey._size) / 2)
            {
                // If reach prey, eat it
                EatEntity(prey);
            }
            else
            {
                // Else, move toward it
                MoveToward(preyPosition, _speed);
            }
        }
    }
Пример #3
0
        // Handle to begin adding template dialogue
        public void AddEntity_Click(object sender, RoutedEventArgs e)
        {
            // Show dialogue
            NewEntity window = new NewEntity();

            window.Owner = this;
            window.Show();
        }
Пример #4
0
 public void EatEntity(NewEntity entity)
 {
     Debug.Log(name + " have eaten " + entity.name);
     _size += entity._size / 2;
     ActualizeSize();
     entity.Die();
     _currentEnergy = _baseEnergy;
     _isHungry      = false;
     _status        = Status.idle;
 }
Пример #5
0
 public void MoveToward(NewEntity target, float speed, bool flee = false)
 {
     if (flee)
     {
         transform.Translate(Vector3.Normalize(transform.position - target.transform.position) * speed);
     }
     else
     {
         transform.Translate(Vector3.Normalize(target.transform.position - transform.position) * speed);
     }
 }
Пример #6
0
    public NewEntity ChoosePrey(List <NewEntity> entities)
    {
        NewEntity nearestEntity = entities [0];

        foreach (NewEntity prey in entities)
        {
            if (Vector3.Distance(prey.transform.position, transform.position) < Vector3.Distance(nearestEntity.transform.position, transform.position))
            {
                nearestEntity = prey;
            }
        }
        nearestEntity.ChasedBy(this);
        return(nearestEntity);
    }
Пример #7
0
        public DataTable sendNewEntity(NewEntity u)
        {
            DataTable dt = new DataTable();

            using (var conn = new SqlConnection(Properties.Settings.Default.SqlConQuery))
                try
                {
                    using (var command = new SqlCommand("Update_Locations", conn)
                    {
                        CommandType = CommandType.StoredProcedure
                    })
                    {
                        conn.Open();
                        command.Parameters.Clear();
                        command.Parameters.AddWithValue("@IDl", (object)u.Id_Location ?? DBNull.Value);
                        command.Parameters.AddWithValue("@IDc", u.Id_City);
                        command.Parameters.AddWithValue("@IDlt", u.Id_EntityType);
                        command.Parameters.AddWithValue("@lat", u.Latitude);
                        command.Parameters.AddWithValue("@lon", u.Longitude);
                        command.Parameters.AddWithValue("@descrip", u.description);
                        command.Parameters.AddWithValue("@url", u.URL);
                        command.Parameters.AddWithValue("@coords", u.coords);
                        command.Parameters.AddWithValue("@address", u.address);
                        command.Parameters.AddWithValue("@zip", u.ZIPcode);
                        command.Parameters.AddWithValue("@Status", u.Status);
                        var Smsg = command.Parameters.Add("msg", SqlDbType.VarChar);
                        Smsg.Direction = ParameterDirection.ReturnValue;
                        var IDS = command.Parameters.Add("ID", SqlDbType.VarChar);
                        IDS.Direction = ParameterDirection.ReturnValue;
                        var Val = command.Parameters.Add("Validacion", SqlDbType.VarChar);
                        Val.Direction = ParameterDirection.ReturnValue;
                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            dt.Load(dr);
                        }
                        conn.Close();
                    }
                    //System.Windows.Forms.MessageBox.Show("Save Succeed");
                    //Console.WriteLine(dt.Rows[0].ItemArray[1].ToString()+"+");
                }
                catch (SqlException a)
                {
                    Console.WriteLine("The process failed: {0}", a.ToString());
                }
            return(dt);
        }
Пример #8
0
        public void Execute(IServiceProvider serviceProvider)
        {
            myService = new MyService(serviceProvider);
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            if (myService.context.MessageName == "bsd_CreateDeliveryPlan")
            {
                string Issubmit = context.InputParameters["Issubmit"].ToString();
                // throw new Exception("okie");
                EntityReference target = myService.getTargetEntityReference();
                myService.StartService();
                Entity suborder = myService.service.Retrieve(target.LogicalName, target.Id, new ColumnSet(true));
                if (!suborder.HasValue("bsd_requestedshipdate") || !suborder.HasValue("bsd_requestedreceiptdate"))
                {
                    throw new Exception("You must provice a value for Ship Date and Receipt Date");
                }
                if (myService.context.Depth > 1)
                {
                    return;
                }

                #region check số lượng trên suborder
                EntityCollection list_noquantity = myService.FetchXml(@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                  <entity name='bsd_suborderproduct'>
                    <attribute name='bsd_suborderproductid' />
                    <filter type='and'>
                      <condition attribute='bsd_suborder' operator='eq' uitype='bsd_suborder' value='" + suborder.Id + @"' />
                      <condition attribute='bsd_shipquantity' operator='eq' value='0' />
                    </filter>
                  </entity>
                </fetch>");
                if (list_noquantity.Entities.Any())
                {
                    "No Quantity To Create Delivery Schedule".Throw();
                }
                #endregion

                #region Check existing
                EntityCollection list_deliveryplan = myService.RetrieveOneCondition("bsd_deliveryplan", "bsd_suborder", target.Id);
                if (list_deliveryplan.Entities.Any())
                {
                    throw new Exception("Đã tạo rồi");
                }
                #endregion

                Entity deliveryplan = new Entity("bsd_deliveryplan");
                deliveryplan["bsd_suborder"] = target;
                try
                {
                    deliveryplan["bsd_type"] = suborder["bsd_type"];
                    // vinhlh 21-12-2017 suborder Site Kí gửi
                    if (((OptionSetValue)suborder["bsd_typeorder"]).Value == 861450002)
                    {
                        EntityReference site_Consignment = getDefaultConfig();
                        deliveryplan["bsd_site"] = new EntityReference(site_Consignment.LogicalName, site_Consignment.Id);
                        //Entity Site_Consignment = myService.service.Retrieve(site_Consignment.LogicalName, site_Consignment.Id, new ColumnSet("bsd_address"));
                        //if (Site_Consignment.HasValue("bsd_address"))
                        //    deliveryplan["bsd_siteaddress"] = (EntityReference)Site_Consignment["bsd_address"];
                    }
                    //end vinhlh
                }
                catch { }
                NewEntity ne = new NewEntity(suborder, deliveryplan);
                ne.Set("bsd_order", true);
                ne.Set("bsd_quote", true);
                ne.Set("bsd_potentialcustomer", true);
                ne.Set("bsd_addresscustomeraccount", true);
                ne.Set("bsd_telephone", true);
                ne.Set("bsd_contact", true);
                ne.Set("bsd_requestedshipdate", true);
                ne.Set("bsd_requestedreceiptdate", true);
                ne.Set("bsd_confirmedreceiptdate", true);
                ne.Set("bsd_historyreceiptcustomer", true);
                ne.Set("bsd_shiptoaccount", "bsd_potentialcustomer", true);
                ne.Set("bsd_shiptoaddress", "bsd_shiptoaddress", true);
                // vinhlh 21-12-2017 suborder Site Kí gửi
                if (suborder.HasValue("bsd_typeorder"))
                {
                    if (((OptionSetValue)suborder["bsd_typeorder"]).Value != 861450002)
                    {
                        ne.Set("bsd_site", true);
                        //ne.Set("bsd_siteaddress", true);
                    }
                }
                else
                {
                    ne.Set("bsd_site", true);
                    //ne.Set("bsd_siteaddress", true);
                }
                //end vinhlh
                ne.Set("bsd_siteaddress", true);
                ne.Set("bsd_port", true);
                ne.Set("bsd_addressport", true);
                ne.Set("bsd_shippingaddress", true);
                ne.Set("bsd_shippingfromaddress", true);
                ne.Set("bsd_deliveryfrom", true);
                ne.Set("bsd_carrier", true);
                ne.Set("bsd_transportation", true);
                ne.Set("bsd_requestporter", true);

                Guid             deliveryplan_id  = myService.service.Create(deliveryplan);
                EntityCollection list_sub_product = myService.RetrieveOneCondition("bsd_suborderproduct", "bsd_suborder", suborder.Id);
                if (list_sub_product.Entities.Any())
                {
                    EntityReference deliveryplan_ref = new EntityReference("bsd_deliveryplan", deliveryplan_id);
                    foreach (var item in list_sub_product.Entities)
                    {
                        Entity deliveryplan_product = new Entity("bsd_deliveryplanproduct");
                        deliveryplan_product["bsd_deliveryplan"] = deliveryplan_ref;
                        deliveryplan_product["bsd_unit"]         = item["bsd_unit"];
                        deliveryplan_product["bsd_product"]      = item["bsd_product"];
                        if (item.HasValue("bsd_productid"))
                        {
                            deliveryplan_product["bsd_productid"] = item["bsd_productid"];
                        }
                        if (item.HasValue("bsd_descriptionproduct"))
                        {
                            deliveryplan_product["bsd_descriptionproduct"] = item["bsd_descriptionproduct"];
                        }
                        if (deliveryplan_product.HasValue("bsd_orderquantity"))
                        {
                            deliveryplan_product["bsd_orderquantity"] = item["bsd_orderquantity"];
                        }

                        //huy
                        if (!item.HasValue("bsd_appendixcontract"))//hợp đồng không có phục lục thì tính bình thường
                        {
                            deliveryplan_product["bsd_shipquantity"]      = item["bsd_shipquantity"];
                            deliveryplan_product["bsd_remainingquantity"] = item["bsd_shipquantity"];
                            deliveryplan_product["bsd_remainaddtruck"]    = item["bsd_shipquantity"];
                        }
                        else//có phụ lục thì tính theo số lượng phụ lục + số lượng trong order
                        {
                            deliveryplan_product["bsd_shipquantity"]      = item["bsd_newquantity"];
                            deliveryplan_product["bsd_remainingquantity"] = item["bsd_newquantity"];
                            deliveryplan_product["bsd_remainaddtruck"]    = item["bsd_newquantity"];
                        }
                        //end huy
                        if (item.HasValue("bsd_standardquantity"))
                        {
                            deliveryplan_product["bsd_standardquantity"] = item["bsd_standardquantity"];
                        }
                        // setname.
                        Entity product = myService.service.Retrieve("product", ((EntityReference)item["bsd_product"]).Id, new ColumnSet("name"));
                        deliveryplan_product["bsd_name"] = product["name"];
                        // setname

                        myService.service.Create(deliveryplan_product);
                    }
                }
                else
                {
                    throw new Exception("No Product to create Delivery Plan !");
                }

                #region cập nhật lai created delivery plan của suborder
                Entity new_suborder = new Entity(suborder.LogicalName, suborder.Id);
                new_suborder["bsd_createddeliveryplan"] = true;
                myService.Update(new_suborder);
                #endregion

                #region Phong 2-2-2018 Approve

                if (Issubmit.ToLower().Trim().Equals("true"))
                {
                    string entityName = context.InputParameters["Entity"].ToString();

                    Guid   RecordID      = Guid.Parse(context.InputParameters["ObjectId"].ToString());
                    Guid   StageId       = Guid.Parse(context.InputParameters["StageId"].ToString());
                    Guid   User          = Guid.Parse(context.InputParameters["Username"].ToString());
                    string attributeName = context.InputParameters["Attribute"].ToString();
                    string approveperson = context.InputParameters["Approveperson"].ToString();
                    string Approvedate   = context.InputParameters["Approvedate"].ToString();
                    string traversedpath = context.InputParameters["StageId"].ToString();


                    int attributeValue = int.Parse(context.InputParameters["Value"].ToString());

                    //Guid gUserId = ((WhoAmIResponse)myService.service.Execute(new WhoAmIRequest())).UserId;

                    Entity updatedStage = new Entity(entityName);
                    SuborderService.Stage_Aprrove(myService.service, entityName, RecordID, User, StageId, traversedpath, attributeName, attributeValue, approveperson, Approvedate, updatedStage);
                }
                #endregion

                myService.context.OutputParameters["ReturnId"] = deliveryplan_id.ToString();
            }

            #region delete
            else if (myService.context.MessageName == "Delete")
            {
                // Cập nhật suborder
                myService.StartService();
                EntityReference target       = myService.getTargetEntityReference();
                Entity          deliveryplan = myService.service.Retrieve(target.LogicalName, target.Id, new ColumnSet("bsd_suborder"));
                Entity          suborder     = new Entity("bsd_suborder", ((EntityReference)deliveryplan["bsd_suborder"]).Id);
                suborder["bsd_createddeliveryplan"] = false;
                myService.service.Update(suborder);
            }
            #endregion
        }
Пример #9
0
        public JsonResult GetSSJKNumbers()
        {
            //System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            //stopwatch.Start();


            int month = 1;

            if (DateTime.Now.Month < 4)
            {
                month = 1;
            }
            else if (DateTime.Now.Month < 7)
            {
                month = 4;
            }
            else if (DateTime.Now.Month < 10)
            {
                month = 7;
            }
            else if (DateTime.Now.Month <= 12)
            {
                month = 10;
            }
            DateTime sdt  = new DateTime(DateTime.Now.Year, month, 1); //当前季度开始日期
            DateTime nsdt = new DateTime(DateTime.Now.Year, month, 1);
            var      user = OperatorProvider.Provider.Current();

            if (user.DeptId == "0")
            {
                user.DeptCode = "0";
            }
            //var all = service.GetMeeting(user.DeptCode, sdt.ToString("yyyy-MM-dd")); //各班组开展班会数量
            var ldt   = service.GetLllegals(user.DeptId, sdt.ToString("yyyy-MM-dd"));     //各班组未整改违章数量
            var edudt = service.GetEducations(user.DeptCode, sdt.ToString("yyyy-MM-dd")); //各班组未评价的教育培训活动

            var acdt = service.GetActivitys(user.DeptCode, sdt.ToString("yyyy-MM-dd"));

            var kytdt = service.GetDanger(user.DeptCode, sdt.ToString("yyyy-MM-dd"));


            var edt  = DateTime.Now;
            int days = (edt - sdt).Days;
            int wd   = 0;

            while (sdt < edt) //循环比较,获得工作日数量
            {
                if (sdt.DayOfWeek != DayOfWeek.Saturday && sdt.DayOfWeek != DayOfWeek.Sunday)
                {
                    ++wd;
                }
                sdt = sdt.AddDays(1);
            }


            int           s         = wd * 2; //应开展班会数量
            int           bzcount   = 0;
            int           meetings  = 0;
            DepartmentBLL deptBll   = new DepartmentBLL();
            var           groups    = deptBll.GetAllGroups().Where(x => x.EnCode.Contains(user.DeptCode));
            int           meet      = 0;
            int           undo      = 0;
            int           undogroup = 0;

            foreach (DepartmentEntity d in groups)
            {
                bool b = false;
                for (int i = 0; i < s; i++)
                {
                    meet = service.GetUndoMeeting(d.DepartmentId, nsdt.AddDays(i).ToString("yyyy-MM-dd"), nsdt.AddDays(i + 1).ToString("yyyy-MM-dd"));
                    if (meet == 0)
                    {
                        b = true;
                        undo++;
                    }
                }
                if (b)           //该班组有未开展的活动
                {
                    undogroup++; //班组数量+1
                }
            }
            bzcount = undogroup;
            var total1 = undo;

            //违章
            int count1 = 0;
            int count2 = 0;

            foreach (DataRow row in ldt.Rows)
            {
                if (Convert.ToInt32(row[2]) != 0)
                {
                    ++count1;
                    count2 += Convert.ToInt32(row[2]);
                }
            }

            //教育培训
            int count3 = 0;
            int count4 = 0;

            foreach (DataRow row in edudt.Rows)
            {
                if (Convert.ToInt32(row[2]) != 0)
                {
                    ++count3;
                    count4 += Convert.ToInt32(row[2]);
                }
            }


            //安全日活动

            DateTime dtWeekSt1; //季度开始日,周开始日期
            DateTime dtWeekSt2; //当前周开始日期
            int      w1 = (int)nsdt.DayOfWeek;
            int      w2 = (int)DateTime.Now.DayOfWeek;

            if (w1 == 0)
            {
                w1 = 7;
            }
            if (w2 == 0)
            {
                w2 = 7;
            }
            dtWeekSt1 = nsdt.AddDays(1 - w1);
            dtWeekSt2 = DateTime.Now.AddDays(1 - w2);
            TimeSpan ts     = dtWeekSt2 - dtWeekSt1;
            int      weeks  = (int)ts.Days / 7; //周数 == 应开展数量
            int      count5 = 0;
            int      count6 = 0;
            int      acs    = 0;



            var total = 0;
            int g     = 0;
            int n     = 0;
            var data  = new List <newActivity>();

            var bll = new ActivityBLL();

            foreach (DepartmentEntity d in groups)
            {
                var  dept = deptBll.GetEntity(d.ParentId);
                bool b    = false;
                for (int i = 0; i < weeks; i++)
                {
                    n = bll.GetActivityList(d.DepartmentId, nsdt.AddDays(i * 7).ToString("yyyy-MM-dd"), nsdt.AddDays((i + 1) * 7).ToString("yyyy-MM-dd"));
                    if (n == 0)
                    {
                        b = true;
                        total++;
                        //data.Add(new newActivity { GroupName = d.FullName, FromTo = sdt.AddDays(i * 7).ToString("yyyy-MM-dd") + "至" + sdt.AddDays((i + 1) * 7).ToString("yyyy-MM-dd"), Remark = "", DeptName = dept == null ? "" : dept.FullName });
                    }
                }
                if (b)   //该班组有未开展的活动
                {
                    g++; //班组数量+1
                }
            }
            count5 = g;
            count6 = total;


            //KYT
            int count7 = 0;
            int count8 = 0;

            foreach (DataRow row in kytdt.Rows)
            {
                if (Convert.ToInt32(row[2]) != 0)
                {
                    ++count7;
                    count8 += Convert.ToInt32(row[2]);
                }
            }

            //stopwatch.Stop();
            //var sec = stopwatch.Elapsed.TotalSeconds;


            var    abll    = new ActivityService();
            var    ebll    = new EduBaseInfoService();
            var    mbll    = new WorkmeetingService();
            string code    = user.DeptCode;
            var    alist   = service.GetActs(code);
            var    edulist = service.GetEdus(code);
            var    mlist   = service.GetDangers(code);
            var    entity  = new NewEntity();
            var    data1   = new List <string>();

            foreach (ActivityEntity a in alist)
            {
                data1.Add(a.GroupId);
            }
            foreach (EduBaseInfoEntity a in edulist)
            {
                data1.Add(a.BZId);
            }
            foreach (DangerEntity a in mlist)
            {
                data1.Add(a.GroupId);
            }
            count4 = data1.Count;
            count3 = data1.Distinct().Count();
            var res = service.FindCount(code);

            return(Json(new { meeting1 = bzcount, meeting2 = total1, lllegals1 = count1, lllegals2 = count2, edu1 = count3, edu2 = count4, activity1 = count5, activity2 = count6, kyt1 = count7, kyt2 = count8 }));
        }
Пример #10
0
        public void Execute(IServiceProvider serviceProvider)
        {
            myService = new MyService(serviceProvider);
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            if (myService.context.Depth > 1)
            {
                return;
            }

            ITracingService tracing = myService.GetTracingService();

            if (myService.context.MessageName == "bsd_Action_CreateDeliveryPlanReturnType")
            {
                string Issubmit = context.InputParameters["Issubmit"].ToString();
                // throw new Exception("okie");
                EntityReference target = myService.getTargetEntityReference();
                myService.StartService();
                Entity suborder = myService.service.Retrieve(target.LogicalName, target.Id, new ColumnSet(true));

                int subtype = ((OptionSetValue)suborder["bsd_type"]).Value;
                if (subtype == 861450004)
                {
                    string trace = "0";
                    try
                    {
                        #region
                        EntityCollection list_deliveryplan = myService.RetrieveOneCondition("bsd_deliveryplan", "bsd_suborder", target.Id);
                        if (list_deliveryplan.Entities.Any())
                        {
                            throw new Exception("Đã tạo rồi1");
                        }

                        Entity deliveryplan = new Entity("bsd_deliveryplan");
                        deliveryplan["bsd_suborder"] = target;
                        if (suborder.HasValue("bsd_type"))
                        {
                            deliveryplan["bsd_type"] = suborder["bsd_type"];
                        }
                        if (suborder.HasValue("bsd_transportation"))
                        {
                            deliveryplan["bsd_transportation"] = suborder["bsd_transportation"];
                        }
                        //throw new Exception("OK " + suborder["bsd_transportation"].ToString());
                        NewEntity ne = new NewEntity(suborder, deliveryplan);
                        trace = "1";
                        ne.Set("bsd_order", true);
                        ne.Set("bsd_quote", true);
                        ne.Set("bsd_potentialcustomer", true);
                        ne.Set("bsd_historyreceiptcustomer", true);
                        //ne.Set("bsd_timeship", true);
                        ne.Set("bsd_addresscustomeraccount", true);
                        ne.Set("bsd_telephone", true);
                        ne.Set("bsd_contact", true);
                        ne.Set("bsd_requestedshipdate", true);
                        ne.Set("bsd_requestedreceiptdate", true);
                        ne.Set("bsd_confirmedreceiptdate", true);
                        ne.Set("bsd_warehousefrom", true);
                        ne.Set("bsd_shiptoaddress", true);
                        ne.Set("bsd_site", true);
                        ne.Set("bsd_siteaddress", true);
                        trace = "2";
                        Guid             deliveryplan_id  = myService.service.Create(deliveryplan);
                        EntityCollection list_sub_product = myService.RetrieveOneCondition("bsd_suborderproduct", "bsd_suborder", suborder.Id);
                        if (list_sub_product.Entities.Any())
                        {
                            trace = "2.1";
                            EntityReference deliveryplan_ref = new EntityReference("bsd_deliveryplan", deliveryplan_id);
                            foreach (var item in list_sub_product.Entities)
                            {
                                trace = "2.2";
                                Entity deliveryplan_product = new Entity("bsd_deliveryplanproduct");
                                deliveryplan_product["bsd_deliveryplan"] = deliveryplan_ref;
                                trace = "2.2";
                                deliveryplan_product["bsd_unit"] = item["bsd_unit"];
                                trace = "2.3";
                                deliveryplan_product["bsd_product"] = item["bsd_product"];
                                trace = "2.4";
                                if (deliveryplan_product.HasValue("bsd_orderquantity"))
                                {
                                    deliveryplan_product["bsd_orderquantity"] = Math.Abs((decimal)item["bsd_orderquantity"]);
                                }
                                trace = "2.5";
                                deliveryplan_product["bsd_shipquantity"]      = Math.Abs((decimal)item["bsd_shipquantity"]);
                                deliveryplan_product["bsd_remainingquantity"] = Math.Abs((decimal)item["bsd_shipquantity"]);
                                deliveryplan_product["bsd_remainaddtruck"]    = Math.Abs((decimal)item["bsd_shipquantity"]);
                                trace = "2.6";
                                if (item.HasValue("bsd_warehouse"))
                                {
                                    deliveryplan_product["bsd_warehouse"] = item["bsd_warehouse"];
                                }
                                trace = "2.7";
                                deliveryplan_product["bsd_standardquantity"] = item["bsd_standardquantity"];
                                trace = "2.8";
                                // setname.
                                Entity product = myService.service.Retrieve("product", ((EntityReference)item["bsd_product"]).Id, new ColumnSet(true));
                                if (product.HasValue("name"))
                                {
                                    deliveryplan_product["bsd_name"] = product["name"];
                                }
                                // setname
                                trace = "2.9";
                                myService.service.Create(deliveryplan_product);
                            }
                        }
                        trace = "3";
                        #region cập nhật lai created delivery plan của suborder
                        Entity new_suborder = new Entity(suborder.LogicalName, suborder.Id);
                        new_suborder["bsd_createddeliveryplan"] = true;
                        myService.Update(new_suborder);
                        #endregion
                        trace = "4";
                        #region Phong 2-2-2018 Approve

                        if (Issubmit.ToLower().Trim().Equals("true"))
                        {
                            string entityName = context.InputParameters["Entity"].ToString();

                            Guid   RecordID      = Guid.Parse(context.InputParameters["ObjectId"].ToString());
                            Guid   StageId       = Guid.Parse(context.InputParameters["StageId"].ToString());
                            Guid   User          = Guid.Parse(context.InputParameters["Username"].ToString());
                            string attributeName = context.InputParameters["Attribute"].ToString();
                            string approveperson = context.InputParameters["Approveperson"].ToString();
                            string Approvedate   = context.InputParameters["Approvedate"].ToString();
                            string traversedpath = context.InputParameters["StageId"].ToString();


                            int attributeValue = int.Parse(context.InputParameters["Value"].ToString());

                            //Guid gUserId = ((WhoAmIResponse)myService.service.Execute(new WhoAmIRequest())).UserId;

                            Entity updatedStage = new Entity(entityName);
                            Stage_Aprrove(myService.service, entityName, RecordID, User, StageId, traversedpath, attributeName, attributeValue, approveperson, Approvedate, updatedStage);
                        }
                        #endregion
                        myService.context.OutputParameters["ReturnId"] = deliveryplan_id.ToString();
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Plugin_SubOrderReturn:" + ex.Message + trace);
                    }
                }
            }
        }
Пример #11
0
 public void ChasedBy(NewEntity predator)
 {
     _status = Status.fleeing;
     MoveToward(predator, _speed, true);
 }