Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";


            //PackageArrange arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == context.Request["arrangeId"]);
            CoursePackage package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == context.Request["packageId"]);

            LabDB.CoursePackage.DeleteOnSubmit(package);

            try
            {
                LabDB.SubmitChanges();
                LabDB.Connection.Close();
            }
            catch (Exception ex)
            {
                //删除失败返回错误信息。
                context.Response.Write(ex.Message);
                return;
            }

            //删除成功返回1。
            context.Response.Write("1");
        }
Пример #2
0
        public IActionResult CreateCoursePackage([FromBody] CoursePackageDTO coursePackage)
        {
            CoursePackage newlyCreatedCoursePackage = _mapper.Map <CoursePackageDTO, CoursePackage>(coursePackage);

            _choiceRepository.Attach <CoursePackage>(newlyCreatedCoursePackage);
            _choiceRepository.Complete();

            foreach (var item in coursePackage.PackageIncludedItemDTOs)
            {
                PackageIncludedItem packageIncludedItem = new PackageIncludedItem()
                {
                    CoursePackageId = newlyCreatedCoursePackage.CoursePackageId,
                    UK = item.UK,
                    DK = item.DK,
                    //Included = item.Included,
                    SortingOrder   = item.SortingOrder,
                    LastModified   = item.LastModified,
                    LastModifiedBy = item.LastModifiedBy,
                    CreatedBy      = item.CreatedBy,
                    CreatedDate    = item.CreatedDate,
                };


                _choiceRepository.Attach(packageIncludedItem);
            }
            _choiceRepository.Complete();



            return(CreatedAtRoute("GetCoursePackageByCoursePackageId", new { coursePackageId = newlyCreatedCoursePackage.CoursePackageId }, newlyCreatedCoursePackage));
        }
Пример #3
0
        public int Compare(Group <GridViewRowInfo> x, Group <GridViewRowInfo> y)
        {
            var xx = x.GetItems().FirstOrDefault()?.Tag;
            var yy = y.GetItems().FirstOrDefault()?.Tag;

            if (xx != null && yy != null)
            {
                CoursePackage xxx = null;
                CoursePackage yyy = null;

                if (xx is CoursePackage)
                {
                    xxx = xx as CoursePackage;
                }
                if (yy is CoursePackage)
                {
                    yyy = yy as CoursePackage;
                }

                var xParts = (int)xxx.Status;
                var yParts = (int)yyy.Status;;

                if (xParts == yParts)
                {
                    return(0);
                }

                return((xParts < yParts ? -1 : 1) * _sortMultiplier);
            }
            return(-1);
        }
Пример #4
0
        /// <summary>
        /// 是否此实验已经预约过。
        /// </summary>
        /// <param name="student"></param>
        /// <param name="package"></param>
        /// <returns></returns>
        protected bool IsBooked(StudentInfo student, CoursePackage package)
        {
            PackageBookInfo info = LabDB.PackageBookInfo.FirstOrDefault(d => d.StudentInfo == student && d.PackageArrange.CoursePackage == package);

            if (info != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //修改安排。
            if (Request.QueryString["packageId"].isNullorWhiteSpace())
            {
                Arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["arrangeId"]);
                Package = Arrange.CoursePackage;

            }
            //添加新安排。
            else
            {
                Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["packageId"]);

            }

            if (Request.HttpMethod == "POST")
            {
                if (Arrange == null)
                {
                    Arrange = new PackageArrange { CoursePackage = Package };
                    LabDB.PackageArrange.InsertOnSubmit(Arrange);
                }

                //收集安排信息。
                Arrange.CustomTime = Request.Form["CustomTime"];

                try
                {
                    Arrange.Capacity = Int32.Parse(Request.Form["Capacity"]);//Int32的Parse方法可能会抛出错误。

                    LabDB.SubmitChanges();
                }
                catch
                {

                }

                Response.Redirect("PackageArrangeManage.aspx?packageId="+Package.Id);
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //修改安排。
            if (Request.QueryString["packageId"].isNullorWhiteSpace())
            {
                Arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["arrangeId"]);
                Package = Arrange.CoursePackage;
            }
            //添加新安排。
            else
            {
                Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["packageId"]);
            }

            if (Request.HttpMethod == "POST")
            {
                if (Arrange == null)
                {
                    Arrange = new PackageArrange {
                        CoursePackage = Package
                    };
                    LabDB.PackageArrange.InsertOnSubmit(Arrange);
                }

                //收集安排信息。
                Arrange.CustomTime = Request.Form["CustomTime"];

                try
                {
                    Arrange.Capacity = Int32.Parse(Request.Form["Capacity"]);//Int32的Parse方法可能会抛出错误。

                    LabDB.SubmitChanges();
                }
                catch
                {
                }

                Response.Redirect("PackageArrangeManage.aspx?packageId=" + Package.Id);
            }
        }
Пример #7
0
        public void InsertData()
        {
            try
            {
                List      oListData = ClientContext.Web.Lists.GetByTitle("Service katalog");
                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                ListItemCollection oListDataItem = oListData.GetItems(camlQuery);
                ClientContext.Load(oListDataItem);
                ClientContext.ExecuteQuery();
                log.Info($"Service katalog List data pulled successfully.");

                foreach (ListItem oItem in oListDataItem)
                {
                    try
                    {
                        log.Info($"Service katalog process started [Id]:{oItem.GetId()}");
                        var coursepack = new CoursePackage();
                        coursepack.SharepointId         = oItem.GetId();
                        coursepack.CoursePackageName    = oItem["Title"].ToString();
                        coursepack.CreatedDate          = oItem.GetCreateDate();
                        coursepack.LastModified         = oItem.GetModifiedDate();
                        coursepack.Offered              = oItem["Offered"].ToBoolean();
                        coursepack.Price                = oItem["Price"].ToDecimal();
                        coursepack.CreatedBy            = oItem.GetAuthor();
                        coursepack.LastModifiedBy       = oItem.GetEditor();
                        coursepack.PackageIncludedItems = new List <PackageIncludedItem>();
                        var childData = oItem["IncludedInPriceDefault"].ParseString();
                        foreach (string[] item in childData)
                        {
                            coursepack.PackageIncludedItems.Add(
                                new PackageIncludedItem
                            {
                                CoursePackageId = coursepack.CoursePackageId,
                                DK             = item[0],
                                UK             = item[1],
                                Included       = item[2].ToBoolean(defaultData: true),
                                SortingOrder   = item[3].ToInt(),
                                CreatedBy      = coursepack.CreatedBy,
                                CreatedDate    = coursepack.CreatedDate,
                                LastModified   = coursepack.LastModified,
                                LastModifiedBy = coursepack.LastModifiedBy
                            });
                        }
                        DKBSDbContext.CoursePackage.Add(coursepack);
                        DKBSDbContext.SaveChanges();
                        log.Info($"Service katalog process completed [Id]:{oItem.GetId()}");
                    }
                    catch (Exception ex)
                    {
                        ErrorCount += 1;
                        log.Error($"Error:Service katalog [Id]:{oItem.GetId().ToString()}", ex);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorCount += 1;
                log.Error($"Error:Unable to pull Service katalog.", ex);
            }
            log.Info($"Total ErrorCount:{ErrorCount}");
        }
Пример #8
0
        public void InsertData(ClientContext clientContext, DKBSDbContext dbContext)
        {
            // sample msg remove later
            log.Info("BookingService upload started.");
            log.Error("BookingService err started.");


            try
            {
                Console.WriteLine(" Successfully Connected");

                List oList = clientContext.Web.Lists.GetByTitle("Bookinger");
                ContentTypeCollection ctColl = oList.ContentTypes;
                clientContext.Load(ctColl);
                clientContext.ExecuteQuery();
                foreach (ContentType ct in ctColl)
                {
                    if (ct.Name == "Bookinger" || ct.Name == "Gamle sager")
                    {
                        Console.WriteLine(ct.Name);
                        Console.WriteLine("---Please wait while list item is displaying.---");
                        //                   try
                        //                 {
                        {
                            string contentTypeName = ct.Name;
                            ListItemCollectionPosition position = null;
                            var page = 1;
                            do
                            {
                                var query = new CamlQuery()
                                {
                                    ViewXml = String.Format("<View Scope='Recursive'><Query><Where><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>{0}</Value></Eq></Where></Query><RowLimit>300</RowLimit></View>", contentTypeName)
                                };
                                query.ListItemCollectionPosition = position;
                                ListItemCollection collListItem = oList.GetItems(query);
                                clientContext.Load(collListItem);
                                clientContext.ExecuteQuery();
                                position = collListItem.ListItemCollectionPosition;
                                Console.WriteLine(position);
                                foreach (ListItem oListItem in collListItem)
                                {
                                    Console.WriteLine("ID: {0} \nTitle: {1} ", oListItem.Id, oListItem["Title"]);
                                    //Console.WriteLine(((SP.FieldUserValue)(oListItem["Author"])).LookupValue);
                                    //Console.WriteLine(((SP.FieldUserValue)(oListItem["Editor"])).LookupValue);
                                    Console.WriteLine(oListItem["Created"].ToString());
                                    Console.WriteLine(oListItem["Modified"].ToString());
                                    Console.WriteLine(oListItem["Modified"]);
                                    Console.WriteLine(oListItem["ProcedureInfo"]);

                                    Console.WriteLine(oListItem["ITProcedureReasonComments"]);
                                    Console.WriteLine(oListItem["Flow"]);
                                    Console.WriteLine(oListItem["Parkeret_x0020_indtil"]);
                                    Console.WriteLine(oListItem["OrderView"]);
                                    Console.WriteLine(oListItem["InternalHistoryNote"]);
                                    Console.WriteLine(oListItem["FirstClosingDate"]);
                                    Console.WriteLine(oListItem["MeetingSeries"]);
                                    Console.WriteLine(oListItem["AdditionalSeriesText"]);
                                    Console.WriteLine(oListItem["IsMainSeriesCase"]);
                                    Console.WriteLine(oListItem["MailLanguage"]);

                                    Console.WriteLine(oListItem["Ankomst"]);
                                    Console.WriteLine(oListItem["Afrejse"]);
                                    Console.WriteLine(oListItem["Eksakte_x0020_oplysninger_x0020_"]);
                                    Console.WriteLine(oListItem["Vores_x0020_noter"]);
                                    Console.WriteLine(oListItem["Form_x00e5_l"]);
                                    Console.WriteLine(oListItem["Antal_x0020_deltagere"]);
                                    Console.WriteLine(oListItem["Deltagere"]);
                                    Console.WriteLine(oListItem["Bordopstilling"]);
                                    Console.WriteLine(oListItem["Arrangementtype"]);
                                    Console.WriteLine(oListItem["Antal_x0020_grupperum"]);
                                    Console.WriteLine(oListItem["AlternativtServices"]);

                                    Console.WriteLine(oListItem["Supplerende_x0020__x00f8_nsker_x"]);
                                    Console.WriteLine(oListItem["_x00d8_nsket_x0020_geografisk_x0"]);
                                    Console.WriteLine(oListItem["Responsible"]);
                                    Console.WriteLine(oListItem["Statsaftale"]);
                                    Console.WriteLine(oListItem["Regionsaftale"]);
                                    Console.WriteLine(oListItem["CenterMatching"]);
                                    Console.WriteLine(oListItem["Hvor_x0020_kender_x0020_du_x0020"]);
                                    Console.WriteLine(oListItem["Henvist_x0020_kontaktperson"]);
                                    Console.WriteLine(oListItem["fldEmail"]);
                                    Console.WriteLine(oListItem["fldMobil"]);
                                    Console.WriteLine(oListItem["fldTelefon"]);

                                    Console.WriteLine(oListItem["Henvist_x0020_firma"]);
                                    Console.WriteLine(oListItem["fldAdresse"]);
                                    Console.WriteLine(oListItem["flsBranche"]);
                                    Console.WriteLine(oListItem["Title"]);
                                    Console.WriteLine(oListItem["CanceledStatusDropDown"]);
                                    Console.WriteLine(oListItem["CanceledStatusText"]);
                                    Console.WriteLine(oListItem["Placeringskommentar"]);
                                    Console.WriteLine(oListItem["GreenKeySR"]);
                                    Console.WriteLine(oListItem["AgreementForEmployeesSR"]);
                                    Console.WriteLine(oListItem["DisabledAccessSR"]);

                                    Console.WriteLine(oListItem["BarSR"]);
                                    Console.WriteLine(oListItem["LoungeSR"]);
                                    Console.WriteLine(oListItem["GamesSR"]);
                                    Console.WriteLine(oListItem["SpaSR"]);
                                    Console.WriteLine(oListItem["PoolSR"]);
                                    Console.WriteLine(oListItem["FitnessRoomSR"]);
                                    Console.WriteLine(oListItem["CasinoSR"]);
                                    Console.WriteLine(oListItem["GreenAreaSR"]);
                                    Console.WriteLine(oListItem["AirConSR"]);
                                    Console.WriteLine(oListItem["CookingSchoolSR"]);

                                    Console.WriteLine(oListItem["GolfSR"]);
                                    Console.WriteLine(oListItem["StartDateTime"]);
                                    Console.WriteLine(oListItem["fldStilling"]);
                                    Console.WriteLine(oListItem["fldAfdeling"]);
                                    Console.WriteLine(oListItem["fldHovedorganisation"]);
                                    Console.WriteLine(oListItem["TurnOffNotification"]);
                                    Console.WriteLine(oListItem["SRMID"]);
                                    Console.WriteLine(oListItem["fldNyKunder"]);
                                    Console.WriteLine(oListItem["Read"]);
                                    Console.WriteLine(oListItem["CentretsKommentarerDKBS"]);

                                    Console.WriteLine(oListItem["BogholdersKommentarerDKBS"]);
                                    Console.WriteLine(oListItem["AngivetAfCenterIAltDKBS"]);
                                    Console.WriteLine(oListItem["EstimeretAfDKBSIAlt"]);
                                    Console.WriteLine(oListItem["DifferenceDKBS"]);
                                    Console.WriteLine(oListItem["PlaceringsdatoDKBS"]);
                                    Console.WriteLine(oListItem["AnkomstDKBS"]);
                                    Console.WriteLine(oListItem["DifferenceIDageDKBS"]);
                                    Console.WriteLine(oListItem["ProvisionssatsDKBS"]);
                                    Console.WriteLine(oListItem["ProvisionForArrangementet"]);
                                    Console.WriteLine(oListItem["Henvisninsgssats"]);
                                    Console.WriteLine(oListItem["HenvisningForArrangement"]);
                                    Console.WriteLine(oListItem["LinkToProvisionItem"]);
                                    Console.WriteLine(oListItem["EvalueringDato"]);

                                    CoursePackage obj = new CoursePackage();
                                    dbContext.Add(obj);

                                    if (oListItem["ProvisionLink"] != null)
                                    {
                                        var childIdField = oListItem["ProvisionLink"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["HenvisningsProvisionLink"] != null)
                                    {
                                        var childIdField = oListItem["HenvisningsProvisionLink"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["RequestRelationParent"] != null)
                                    {
                                        var childIdField = oListItem["RequestRelationParent"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Emails"] != null)
                                    {
                                        var childIdField = oListItem["Emails"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Communications"] != null)
                                    {
                                        var childIdField = oListItem["Communications"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["ActionsTaken"] != null)
                                    {
                                        var childIdField = oListItem["ActionsTaken"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }

                                    if (oListItem["ZipMachingFilter"] != null)
                                    {
                                        var childIdField = oListItem["ZipMachingFilter"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Status"] != null)
                                    {
                                        var childIdField = oListItem["Status"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Placering"] != null)
                                    {
                                        var childIdField = oListItem["Placering"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Henvist_x0020_af"] != null)
                                    {
                                        var childIdField = oListItem["Henvist_x0020_af"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["PartnerResponsible"] != null)
                                    {
                                        var childIdField = oListItem["PartnerResponsible"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Origin"] != null)
                                    {
                                        var childIdField = oListItem["Origin"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["PartnerType"] != null)
                                    {
                                        var childIdField = oListItem["PartnerType"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Customer2"] != null)
                                    {
                                        var childIdField = oListItem["Customer2"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["Requester2"] != null)
                                    {
                                        var childIdField = oListItem["Requester2"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                    if (oListItem["CauseOFRemoval"] != null)
                                    {
                                        var childIdField = oListItem["CauseOFRemoval"] as FieldLookupValue[];

                                        if (childIdField != null)
                                        {
                                            foreach (var lookupValue in childIdField)
                                            {
                                                var childId_Value = lookupValue.LookupValue;
                                                var childId_Id    = lookupValue.LookupId;

                                                Console.WriteLine("LookupID: " + childId_Id.ToString());
                                                Console.WriteLine("LookupValue: " + childId_Value.ToString());
                                            }
                                        }
                                    }
                                }
                                page++;
                            }while (position != null);
                        }
                        //dbContext.SaveChanges();
                        //return true;
                        // }
                        // catch (Exception ex)
                        //{
                        //  Console.WriteLine(ex);
                        // }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void InsertData()
        {
            try
            {
                List      oList     = ClientContext.Web.Lists.GetByTitle("Partnere");
                CamlQuery camlQuery = new CamlQuery();
                //<Where><Eq><FieldRef Name='ID' /><Value Type='Text'>49</Value></Eq>
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Where></Query></View>";
                ListItemCollection collListItem = oList.GetItems(camlQuery);
                ClientContext.Load(collListItem);
                ClientContext.ExecuteQuery();
                //get content status Id.
                var contentStatusId = Extension.GetApprovedConentStatusId(DKBSDbContext);
                foreach (ListItem oListItem in collListItem)
                {
                    var hyperLink = ((FieldUrlValue)(oListItem["CISite"]));
                    if (hyperLink != null)
                    {
                        try
                        {
                            var           hLink   = ((FieldUrlValue)(oListItem["CISite"])).Url;
                            ClientContext Context = new ClientContext(hLink);
                            Context.AuthenticationMode           = ClientAuthenticationMode.FormsAuthentication;
                            Context.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo(Configuration["SharePointUserName"], Configuration["SharePointPassword"]);
                            Context.ExecuteQuery();
                            List oListData = Context.Web.Lists.GetByTitle("Kursuspakke");
                            camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                            ListItemCollection oListDataItem = oListData.GetItems(camlQuery);
                            Context.Load(oListDataItem);
                            Context.ExecuteQuery();

                            foreach (ListItem oItem in oListDataItem)
                            {
                                log.Info($"Partner course package data process started Partner Id: {oItem.Id}");
                                try
                                {
                                    log.Info($"Partner course package data process started Kursuspakke: {oItem.Id} Service Catalog Id { oItem["KursuspakkeID"].ToInt(true, 0)}");
                                    CoursePackage        coursePackage  = DKBSDbContext.CoursePackage.Where(p => p.SharepointId == oItem["KursuspakkeID"].ToInt(true, 0)).Single();
                                    CRMPartner           partner        = DKBSDbContext.CRMPartner.Where(p => p.AccountId == oListItem.Id.ToString()).Single();
                                    PartnerCoursePackage partnerPackage = new PartnerCoursePackage();
                                    partnerPackage.CRMPartnerId    = partner.CRMPartnerId;
                                    partnerPackage.SharepointId    = oItem.Id;
                                    partnerPackage.CoursePackageId = coursePackage.CoursePackageId;
                                    partnerPackage.ContentStatusId = contentStatusId;
                                    partnerPackage.Offered         = oItem["Offered"].ToBoolean();
                                    partnerPackage.Price           = oItem["Price"].ToDecimal();
                                    partnerPackage.CreatedDate     = oItem.GetCreateDate();
                                    partnerPackage.LastModified    = oItem.GetModifiedDate();
                                    partnerPackage.LastModifiedBy  = oItem.GetEditor();
                                    partnerPackage.CreatedBy       = oItem.GetAuthor();

                                    var includedPriceDetails = oItem["IncludedInPriceDefault"].ParseString();
                                    var additionalIncluded   = oItem["IncludedInPriceAdditional"].ParseString();
                                    var optionalPurchages    = oItem["OptionalPurchases"].ParseString();
                                    var pricePerYear         = oItem["PricePerYear"].ParseString();

                                    // Included in price
                                    foreach (var item in includedPriceDetails)
                                    {
                                        var packageItem = DKBSDbContext.PackageIncludedItem.First(p => p.CoursePackageId == coursePackage.CoursePackageId && p.DK == item[0]);
                                        PartnerPackageIncludedItem ppi = new PartnerPackageIncludedItem()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy             = oItem.GetAuthor(),
                                            PackageIncludedItemId = packageItem.PackageIncludedItemId,
                                            Offered = item[2].IsChecked(),
                                        };
                                        partnerPackage.PartnerPackageIncludedItems.Add(ppi);
                                    }

                                    // additional included
                                    foreach (var item in additionalIncluded)
                                    {
                                        PartnerPackageAdditionalItem ppai = new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy = oItem.GetAuthor(),
                                            DK        = item[0],
                                            UK        = item[1]
                                        };
                                        partnerPackage.PartnerPackageAdditionalItems.Add(ppai);
                                    }

                                    // optional purchages in price
                                    foreach (var item in optionalPurchages)
                                    {
                                        PartnerPackageAdditionalItem ppai = new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy = oItem.GetAuthor(),
                                            DK        = item[0],
                                            UK        = item[1],
                                            Price     = item[2].ToDecimal(defaultData: true, defaultDataValue: 0).Value
                                        };
                                        partnerPackage.PartnerPackageAdditionalItems.Add(ppai);
                                    }

                                    // Price next year
                                    foreach (var item in pricePerYear)
                                    {
                                        PartnerPackageYear pny = new PartnerPackageYear()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy      = oItem.GetAuthor(),
                                            Year           = item[0].ToInt(true, 0).Value,
                                            PricePerPerson = item[1].ToDecimal(true, 0).Value,
                                        };
                                        partnerPackage.PartnerPackageYears.Add(pny);
                                    }
                                    DKBSDbContext.Add(partnerPackage);
                                    DKBSDbContext.SaveChanges();
                                    log.Info($"Partner course package data process completed Kursuspakke: {oItem.Id} Service Catalog Id { oItem["KursuspakkeID"].ToInt(true, 0)}");
                                }
                                catch (Exception ex)
                                {
                                    ErrorCount += 1;
                                    log.Error($"Error:Unable to insert Course package Kursuspakke Id: {oItem.Id} Service Catalog Id { oItem["KursuspakkeID"].ToInt(true, 0)}", ex);
                                }
                            }
                            log.Info($"Partner course package data process completed Partner Id: {oListItem.Id}");
                        }
                        catch (Exception ex)
                        {
                            ErrorCount += 1;
                            log.Error($"Error:Unable to pull Kursuspakke. PartnerId:{oListItem.Id}", ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error($"Error:Unable to pull Partnere.", ex);
            }
            log.Info($"Total ErrorCount:{ErrorCount}");
        }
Пример #10
0
        public void InsertData(ClientContext clientContext, DKBSDbContext dbContext)
        {
            try
            {
                Console.WriteLine(" Successfully Connected");


                SP.List oList = clientContext.Web.Lists.GetByTitle("Partnere");

                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                ListItemCollection collListItem = oList.GetItems(camlQuery);

                clientContext.Load(collListItem);

                clientContext.ExecuteQuery();

                foreach (ListItem oListItem in collListItem)
                {
                    var hyperLink = ((SP.FieldUrlValue)(oListItem["CISite"]));
                    if (hyperLink != null)
                    {
                        Console.WriteLine("ID: {0} \nTitle: {1} \nSite: {2} \nSiteUrl: {3} ", oListItem.Id, oListItem["Title"], oListItem["CISite"], oListItem["CISiteShortUrl"]);
                        var hLink = ((SP.FieldUrlValue)(oListItem["CISite"])).Url;
                        Console.WriteLine(hLink);


                        ClientContext Context = new ClientContext(hLink);
                        Context.AuthenticationMode           = ClientAuthenticationMode.FormsAuthentication;
                        Context.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo("CRM Automation", "9LEkTny4");
                        Context.ExecuteQuery();
                        SP.List oListData = Context.Web.Lists.GetByTitle("Kursuspakke");

                        camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                        ListItemCollection oListDataItem = oListData.GetItems(camlQuery);

                        Context.Load(oListDataItem);

                        Context.ExecuteQuery();

                        foreach (ListItem oItem in oListDataItem)
                        {
                            Console.WriteLine("ID: {0} \nTitle: {1} \nKursuspakkeUK:{2} \nOffered: {3} \nPrice:{4}", oItem.Id, oItem["Title"], oItem["KursuspakkeUK"], oItem["Offered"], oItem["Price"]);
                            Console.WriteLine("IncludedInPriceAdditional: {0} \nIncludedInPriceDefault:{1} \nOptionalPurchases: {2} \nPricePerYear:{3}", oItem["IncludedInPriceAdditional"], oItem["IncludedInPriceDefault"], oItem["OptionalPurchases"], oItem["PricePerYear"]);
                            Console.WriteLine(((SP.FieldUserValue)(oItem["Author"])).LookupValue);
                            Console.WriteLine(((SP.FieldUserValue)(oItem["Editor"])).LookupValue);
                            Console.WriteLine(oItem["Created"].ToString());
                            Console.WriteLine(oItem["Modified"].ToString());
                            Console.WriteLine(oItem["KursuspakkeID"]);
                            CoursePackage        coursePackage        = dbContext.CoursePackage.Where(p => p.CoursePackageName == oItem["Title"].ToString()).First();
                            PartnerCoursePackage partnerCoursePackage = new PartnerCoursePackage();
                            PartnerPackageYear   partnerPackageYear   = new PartnerPackageYear();
                            // partnerCoursePackage.CRMPartnerId = oListItem.Id;
                            partnerCoursePackage.CRMPartnerId    = 1; //hard-coded value for test purpose
                            partnerCoursePackage.CoursePackageId = coursePackage.CoursePackageId;
                            // partnerCoursePackage.CoursePackageId = oItem.Id;
                            partnerCoursePackage.ContentStatusId = 1;    //hard-coded value for test purpose
                            partnerCoursePackage.Offered         = Convert.ToBoolean(oItem["Offered"]);
                            partnerCoursePackage.Price           = Convert.ToDecimal(oItem["Price"]);
                            partnerCoursePackage.CreatedDate     = Convert.ToDateTime(oItem["Created"].ToString());
                            partnerCoursePackage.LastModified    = Convert.ToDateTime(oItem["Modified"].ToString());
                            partnerCoursePackage.LastModifiedBy  = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue;
                            partnerCoursePackage.CreatedBy       = ((SP.FieldUserValue)(oItem["Author"])).LookupValue;

                            partnerPackageYear.PartnerCoursePackageId = oItem.Id;
                            // if(oItem["PricePerYear"] != null) partnerPackageYear.Year = Convert.ToInt32(oItem["PricePerYear"]);
                            partnerPackageYear.CreatedDate    = Convert.ToDateTime(oItem["Created"].ToString());
                            partnerPackageYear.LastModified   = Convert.ToDateTime(oItem["Modified"].ToString());
                            partnerPackageYear.LastModifiedBy = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue;
                            partnerPackageYear.CreatedBy      = ((SP.FieldUserValue)(oItem["Author"])).LookupValue;
                            //partnerPackageYear.PricePerPerson = oItem.

                            if (oItem["IncludedInPriceDefault"] != null)
                            {
                                ArrayList parsedData = new ArrayList();
                                partnerCoursePackage.PartnerPackageIncludedItems = new List <PartnerPackageIncludedItem>();
                                SharedFunctions sharedFunctions = new SharedFunctions();
                                parsedData = sharedFunctions.ParseFunction(oItem["IncludedInPriceDefault"].ToString());
                                if (parsedData.Count > 0)
                                {
                                    foreach (List <String> pacakageData in parsedData)
                                    {
                                        Console.WriteLine(pacakageData);
                                        Array pacakageDataArray = pacakageData.ToArray();
                                        PackageIncludedItem packageIncludedItem = dbContext.PackageIncludedItem.Where(p => p.DK == pacakageData[0]).First();
                                        partnerCoursePackage.PartnerPackageIncludedItems.Add(new PartnerPackageIncludedItem()
                                        {
                                            PartnerCoursePackageId       = oItem.Id,
                                            PartnerPackageIncludedItemId = packageIncludedItem.PackageIncludedItemId,
                                            Offered = (pacakageData.Count > 2 ? (pacakageData[2] == "checked" ? true : false) : false)
                                        });
                                    }
                                }
                            }
                            //else
                            //{

                            //    partnerCoursePackage.PartnerPackageIncludedItems.Add(new PartnerPackageIncludedItems() { CoursePackageId = Convert.ToInt32(oItem["ID"]) });

                            //}
                            if (oItem["IncludedInPriceAdditional"] != null)
                            {
                                ArrayList parsedData = new ArrayList();
                                partnerCoursePackage.PartnerPackageIncludedItems = new List <PartnerPackageIncludedItem>();
                                SharedFunctions sharedFunctions = new SharedFunctions();
                                parsedData = sharedFunctions.ParseFunction(oItem["IncludedInPriceAdditional"].ToString());
                                if (parsedData.Count > 0)
                                {
                                    foreach (List <String> pacakageData in parsedData)
                                    {
                                        Console.WriteLine(pacakageData);
                                        Array pacakageDataArray = pacakageData.ToArray();

                                        partnerCoursePackage.PartnerPackageAdditionalItems.Add(new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = oItem.Id,
                                            DK             = pacakageData[0],
                                            CreatedDate    = Convert.ToDateTime(oItem["Created"].ToString()),
                                            LastModified   = Convert.ToDateTime(oItem["Modified"].ToString()),
                                            LastModifiedBy = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue,
                                            CreatedBy      = ((SP.FieldUserValue)(oItem["Author"])).LookupValue,
                                            Price          = Convert.ToDecimal(oItem["Price"])
                                        });
                                    }
                                }
                            }
                            if (oItem["OptionalPurchases"] != null)
                            {
                                ArrayList parsedData = new ArrayList();
                                partnerCoursePackage.PartnerPackageIncludedItems = new List <PartnerPackageIncludedItem>();
                                SharedFunctions sharedFunctions = new SharedFunctions();
                                parsedData = sharedFunctions.ParseFunction(oItem["OptionalPurchases"].ToString());
                                if (parsedData.Count > 0)
                                {
                                    foreach (List <String> pacakageData in parsedData)
                                    {
                                        Console.WriteLine(pacakageData);
                                        Array pacakageDataArray = pacakageData.ToArray();

                                        partnerCoursePackage.PartnerPackageAdditionalItems.Add(new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = oItem.Id,
                                            DK             = pacakageData[0],
                                            CreatedDate    = Convert.ToDateTime(oItem["Created"].ToString()),
                                            LastModified   = Convert.ToDateTime(oItem["Modified"].ToString()),
                                            LastModifiedBy = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue,
                                            CreatedBy      = ((SP.FieldUserValue)(oItem["Author"])).LookupValue
                                                             //Price = pacakageData[2] == "" ? 0 : Convert.ToDecimal(pacakageData[2])
                                        });
                                    }
                                }
                            }
                            dbContext.Add(partnerCoursePackage);
                            dbContext.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            #region 检查输入是否完整且合法。

            //实验包名称。
            if (context.Request.Form["name"].isNullorWhiteSpace())
            {
                context.Response.Write("实验包名称不能为空");
                return;
            }

            //实验地点。
            if (context.Request.Form["address"].isNullorWhiteSpace())
            {
                context.Response.Write("实验地点不能为空!");
                return;
            }

            //学时。
            if (context.Request.Form["classHour"].isNullorWhiteSpace())
            {
                context.Response.Write("学时不能为空!");
                return;
            }

            //指导老师。
            if (context.Request.Form["teacherId"].isNullorWhiteSpace())
            {
                context.Response.Write("指导老师不能为空!");
                return;
            }

            #endregion

            if (context.Request.Form["packageId"].isNullorWhiteSpace())
            {
                Package = new CoursePackage     //课程包添加。
                {
                    ExperimentInfo = LabDB.ExperimentInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["experimentId"]),

                };

                LabDB.CoursePackage.InsertOnSubmit(Package);
            }
            else       //课程包修改。
            {
                Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["packageId"]);
                foreach (var packageList in Package.PackagedCourse)
                {
                    LabDB.PackagedCourse.DeleteOnSubmit(packageList);
                }

            }

            Package.Name = context.Request.Form["name"];
            Package.ClassHour = Convert.ToByte(context.Request.Form["classHour"]);
            Package.TeacherInfo = LabDB.TeacherInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["teacherId"]);
            Package.Address = context.Request.Form["address"];

            foreach (var item in context.Request.Form)
            {
                if (Common.RegexValidate("^[0-9]*$", item.ToString()))
                {
                    PackagedCourse packageList = new PackagedCourse
                    {
                        CourseInfo = LabDB.CourseInfo.SingleOrDefault(d => d.Id.ToString() == item.ToString()),
                        CoursePackage = Package,
                    };

                    LabDB.PackagedCourse.InsertOnSubmit(packageList);
                }
            }

            //LabDB.CoursePackage.InsertOnSubmit(Package);

            try
            {
                LabDB.SubmitChanges();
                context.Response.Write("1");
            }
            catch (Exception ex)
            {
                context.Response.Write("错误!" + ex.Message);
            }
        }
Пример #12
0
        public void InsertData(ClientContext clientContext, DKBSDbContext dbContext)
        {
            try
            {
                Console.WriteLine(" Successfully Connected");

                SP.List   oListData = clientContext.Web.Lists.GetByTitle("Service katalog");
                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                ListItemCollection oListDataItem   = oListData.GetItems(camlQuery);
                SharedFunctions    sharedFunctions = new SharedFunctions();

                clientContext.Load(oListDataItem);

                clientContext.ExecuteQuery();

                foreach (ListItem oItem in oListDataItem)
                {
                    Console.WriteLine("ID: {0} \nTitle: {1}", oItem["ID"], oItem["Title"]);
                    Console.WriteLine(((SP.FieldUserValue)(oItem["Author"])).LookupValue);
                    Console.WriteLine(((SP.FieldUserValue)(oItem["Editor"])).LookupValue);
                    Console.WriteLine(oItem["Created"].ToString());
                    Console.WriteLine(oItem["Modified"].ToString());
                    Console.WriteLine(oItem["KursuspakkeUK"]);
                    Console.WriteLine(oItem["Offered"]);
                    Console.WriteLine(oItem["Price"]);
                    Console.WriteLine(oItem["KursuspakkeID"]);
                    Console.WriteLine(oItem["IncludedInPriceDefault"]);
                    Console.WriteLine(oItem["IncludedInPriceAdditional"]);
                    Console.WriteLine(oItem["OptionalPurchases"]);
                    var coursepack = new CoursePackage();
                    coursepack.CoursePackageName = oItem["Title"].ToString();
                    coursepack.CreatedDate       = Convert.ToDateTime(oItem["Created"].ToString());
                    coursepack.LastModified      = Convert.ToDateTime(oItem["Modified"].ToString());
                    //coursepack.Offered = oItem["Offered"].ToString();
                    coursepack.Price = Convert.ToDecimal(oItem["Price"]);
                    //coursepack.CreatedBy = oItem["Author"].ToString();
                    // coursepack.LastModifiedBy = oItem["Editor"].ToString();
                    coursepack.CreatedBy      = (((SP.FieldUserValue)(oItem["Author"])).LookupValue).ToString();
                    coursepack.LastModifiedBy = (((SP.FieldUserValue)(oItem["Editor"])).LookupValue).ToString();
                    ArrayList parsedData = new ArrayList();
                    coursepack.PackageIncludedItems = new List <PackageIncludedItem>();
                    if (oItem["IncludedInPriceDefault"] != null)
                    {
                        parsedData = sharedFunctions.ParseFunction(oItem["IncludedInPriceDefault"].ToString());
                        if (parsedData.Count > 0)
                        {
                            foreach (List <String> pacakageData in parsedData)
                            {
                                Console.WriteLine(pacakageData);
                                Array pacakageDataArray = pacakageData.ToArray();
                                coursepack.PackageIncludedItems.Add(new PackageIncludedItem()
                                {
                                    CoursePackageId = Convert.ToInt32(oItem["ID"]), DK = pacakageData[0].ToString()
                                });
                            }
                        }
                    }
                    else
                    {
                        coursepack.PackageIncludedItems.Add(new PackageIncludedItem()
                        {
                            CoursePackageId = Convert.ToInt32(oItem["ID"])
                        });
                    }
                    dbContext.Add(coursepack);
                    dbContext.SaveChanges();
                    //if (oItem["KursuspakkeTypen"] != null)
                    //{
                    //    Console.WriteLine(oItem["KursuspakkeTypen"]);
                    //    var childIdField = oItem["KursuspakkeTypen"] as FieldLookupValue[];

                    //    if (childIdField != null)
                    //    {
                    //        foreach (var lookupValue in childIdField)
                    //        {
                    //            var childId_Value = lookupValue.LookupValue;
                    //            var childId_Id = lookupValue.LookupId;

                    //            Console.WriteLine("LookupID: " + childId_Id.ToString());
                    //            Console.WriteLine("LookupValue: " + childId_Value.ToString());
                    //        }
                    //    }
                    //}
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            #region 检查输入是否完整且合法。

            //实验包名称。
            if (context.Request.Form["name"].isNullorWhiteSpace())
            {
                context.Response.Write("实验包名称不能为空");
                return;
            }

            //实验地点。
            if (context.Request.Form["address"].isNullorWhiteSpace())
            {
                context.Response.Write("实验地点不能为空!");
                return;
            }

            //学时。
            if (context.Request.Form["classHour"].isNullorWhiteSpace())
            {
                context.Response.Write("学时不能为空!");
                return;
            }



            //指导老师。
            if (context.Request.Form["teacherId"].isNullorWhiteSpace())
            {
                context.Response.Write("指导老师不能为空!");
                return;
            }


            #endregion


            if (context.Request.Form["packageId"].isNullorWhiteSpace())
            {
                Package = new CoursePackage     //课程包添加。
                {
                    ExperimentInfo = LabDB.ExperimentInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["experimentId"]),
                };

                LabDB.CoursePackage.InsertOnSubmit(Package);
            }
            else       //课程包修改。
            {
                Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["packageId"]);
                foreach (var packageList in Package.PackagedCourse)
                {
                    LabDB.PackagedCourse.DeleteOnSubmit(packageList);
                }
            }


            Package.Name        = context.Request.Form["name"];
            Package.ClassHour   = Convert.ToByte(context.Request.Form["classHour"]);
            Package.TeacherInfo = LabDB.TeacherInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["teacherId"]);
            Package.Address     = context.Request.Form["address"];



            foreach (var item in context.Request.Form)
            {
                if (Common.RegexValidate("^[0-9]*$", item.ToString()))
                {
                    PackagedCourse packageList = new PackagedCourse
                    {
                        CourseInfo    = LabDB.CourseInfo.SingleOrDefault(d => d.Id.ToString() == item.ToString()),
                        CoursePackage = Package,
                    };

                    LabDB.PackagedCourse.InsertOnSubmit(packageList);
                }
            }

            //LabDB.CoursePackage.InsertOnSubmit(Package);

            try
            {
                LabDB.SubmitChanges();
                context.Response.Write("1");
            }
            catch (Exception ex)
            {
                context.Response.Write("错误!" + ex.Message);
            }
        }