コード例 #1
0
        public bool PublishFullState()
        {
            presence pres = this.BuildFullPresence();

            if (this.PartialPublication)
            {
                pidffull full = pres as pidffull;
                full.versionSpecified = true;
                full.version          = (this.version++);

                byte[] content = this.SerializeContent(full);
                return(this.PublishContent(content));
            }
            else
            {
                byte[] content = this.SerializeContent(pres);
                return(this.PublishContent(content));
            }
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: BilalZQ/MMP
        public ActionResult AddUser(AddUser newUser)
        {
            using (mmpEntities mP = new mmpEntities())
            {
                ViewBag.roles       = mP.roles.ToList <role>();
                ViewBag.regions     = mP.regions.ToList <region>();
                ViewBag.supervisors = mP.users.Where(a => a.role_id == mP.roles.FirstOrDefault(x => x.role_name == "supervisor").role_id).ToList <user>();
                ViewBag.departments = mP.category_type_details.Where(x => x.category_id == (mP.categories.FirstOrDefault(z => z.category_name == "departments").category_id)).ToList <category_type_details>();
                ViewBag.projects    = mP.category_type_details.Where(x => x.category_id == (mP.categories.FirstOrDefault(z => z.category_name == "projects").category_id)).ToList <category_type_details>();

                ViewBag.supervisorsl = mP.users.Where(a => a.role_id == mP.roles.FirstOrDefault(x => x.role_name == "supervisor").role_id&& a.user_status == "active").Select(p => new SelectListItem()
                {
                    Text  = p.employee_id + "    " + p.user_name,
                    Value = p.user_id.ToString()
                }).ToList();

                #region Employee ID Already Exists
                var isEmployeeIDExists = isEmployeeIDExist(newUser.employee_id);
                if (isEmployeeIDExists)
                {
                    ModelState.AddModelError("EmployeeExist", "Employee already exists");
                    return(View(newUser));
                }
                #endregion

                /*#region User Already Exists
                 * var isUserExists = isUserExist(newUser.user_name);
                 * if (isUserExists)
                 * {
                 *  ModelState.AddModelError("UserExist", "User already exists");
                 *  return View(newUser);
                 * }
                 #endregion*/

                #region Email Already exists
                var isEmailExists = IsEmailExist(newUser.user_email);
                if (isEmailExists)
                {
                    ModelState.AddModelError("EmailExist", "Email already exists");
                    newUser.user_name = "Enter New Name";
                    return(View(newUser));
                }
                #endregion

                if (ModelState.IsValid)
                {
                    ModelState.AddModelError("UserExist", "User already exists");

                    #region Password Hashing
                    newUser.user_password   = Crypto.Hash(newUser.user_password);
                    newUser.confirmPassword = Crypto.Hash(newUser.confirmPassword);
                    #endregion

                    user user = new user()
                    {
                        role_id                 = newUser.role_id,
                        employee_id             = newUser.employee_id,
                        user_name               = newUser.user_name,
                        user_email              = newUser.user_email,
                        designation             = newUser.designation,
                        user_password           = newUser.user_password,
                        created_at              = DateTime.Now,
                        supervisor              = newUser.supervisor,
                        region_id               = newUser.region_id,
                        user_primary_department = newUser.user_primary_department,
                        user_primary_project    = newUser.user_primary_project,
                        user_status             = "active",
                        join_date               = newUser.joining_date
                    };

                    mP.users.Add(user);

                    //var timesheet = mP.timesheet_mr.Where(x => x.tsmr_valid_till > DateTime.Now && x.tsmr_start_date < DateTime.Now).FirstOrDefault<timesheet_mr>();
                    var timesheets = mP.timesheet_mr.Where(x => x.tsmr_valid_till > user.join_date).ToList <timesheet_mr>();
                    foreach (timesheet_mr timesheet in timesheets)
                    {
                        string body;
                        if (timesheet != null)
                        {
                            timesheet ts = new timesheet()
                            {
                                timesheet_user   = user.user_id,
                                time_my          = DateTime.Now,
                                timesheet_status = "saved",
                                timesheet_caller = timesheet.tsmr_id,
                                tsmr_extension   = timesheet.tsmr_valid_till > DateTime.Now ? timesheet.tsmr_valid_till : DateTime.Now.AddDays(-1)
                            };
                            mP.timesheets.Add(ts);


                            foreach (DateTime day in EachDay(timesheet.tsmr_start_date, timesheet.tsmr_valid_till))
                            {
                                presence ps = new presence()
                                {
                                    p_date       = day,
                                    total_hours  = 0,
                                    leave_status = "",
                                    user_id      = user.user_id
                                };
                                mP.presences.Add(ps);
                            }


                            body = "<br></br>" + user.user_name + ", New TimeSheet is assigned to you. TimeSheet is valid Till " + timesheet.tsmr_valid_till + ". Visit the following website to access timeSheet<br></br>" +
                                   "<a href='http://magcom-001-site3.etempurl.com'>http://magcom-001-site3.etempurl.com</a>";

                            Task.Run(() => EmailAlert.SendEmail(user.user_email, body));
                        }
                    }

                    #region Save to Database
                    mP.SaveChanges();
                    #endregion

                    return(Json(new { success = true, message = "Saved Successfully" }));
                }
                else
                {
                    return(Json(new { success = true, message = "Invalid Request" }));
                }
            }
        }
コード例 #3
0
        private presence BuildFullPresence()
        {
            presence pres = this.PartialPublication ? new pidffull() : new presence();

            pres.entity = this.FromUri;

            if (this.personId == null)
            {
                this.personId = String.Format("{0}{1:D7}", "p", ++MyPublicationSession.personIdCounter);
            }

            basic  status = basic.closed;
            String note   = "Offline";

            BogheCore.Generated.rpid.ItemsChoiceType activity = BogheCore.Generated.rpid.ItemsChoiceType.unknown;
            switch (this.PresenceStatus)
            {
            case PresenceStatus.Busy:
                note     = "Busy";
                status   = basic.open;
                activity = BogheCore.Generated.rpid.ItemsChoiceType.busy;
                break;

            case PresenceStatus.Away:
                note     = "Away";
                status   = basic.open;
                activity = BogheCore.Generated.rpid.ItemsChoiceType.away;
                break;

            case PresenceStatus.Online:
                note   = "Online";
                status = basic.open;
                break;

            case PresenceStatus.HyperAvailable:
                note   = "Hyper-Available";
                status = basic.open;
                break;

            case PresenceStatus.BeRightBack:
                note     = "Be Right Back";
                status   = basic.open;
                activity = BogheCore.Generated.rpid.ItemsChoiceType.vacation;
                break;

            case PresenceStatus.OnThePhone:
                note     = "On The Phone";
                status   = basic.open;
                activity = BogheCore.Generated.rpid.ItemsChoiceType.onthephone;
                break;

            case PresenceStatus.OutToLunch:
                note     = "Out To Lunch";
                status   = basic.open;
                activity = BogheCore.Generated.rpid.ItemsChoiceType.meal;
                break;
            }

            /*== Person ==*/
            pres.Persons = new person[1] {
                new person()
            };
            pres.Persons[0].id        = this.personId;
            pres.Persons[0].timestamp = Rfc3339DateTime.ToString(DateTime.UtcNow);

            pres.Persons[0].overridingWillingness = new overridingwillingness();
            pres.Persons[0].overridingWillingness.basicSpecified = true;
            pres.Persons[0].overridingWillingness.basic          = (status == basic.closed) ? basicType.closed : basicType.open;
            if (this.PresenceStatus == PresenceStatus.HyperAvailable)
            {
                /* The RCS HyperAvailability information is carried by the OMA Overriding Willingness combined with an "until" value as specified in
                 * [Presence2.0_DDS], with element basic->open. */
                pres.Persons[0].overridingWillingness.Until = Rfc3339DateTime.ToString(DateTime.UtcNow.AddMinutes(this.HyperAvailabilityTimeout));
            }

            pres.Persons[0].note = new BogheCore.Generated.data_model.Note_t[1] {
                new BogheCore.Generated.data_model.Note_t()
            };
            pres.Persons[0].note[0].Value = String.IsNullOrEmpty(this.FreeText) ? note : this.FreeText;

            pres.Persons[0].activities = new activities();
            pres.Persons[0].activities.ItemsElementName    = new BogheCore.Generated.rpid.ItemsChoiceType[1];
            pres.Persons[0].activities.ItemsElementName[0] = activity;
            pres.Persons[0].activities.Items    = new BogheCore.Generated.rpid.empty[1];
            pres.Persons[0].activities.Items[0] = new BogheCore.Generated.rpid.empty();

            /*pres.Persons[0].mood = new mood();
             * pres.Persons[0].mood.ItemsElementName = new ItemsChoiceType1[1];
             * pres.Persons[0].mood.ItemsElementName[0] = this.Mood;
             * pres.Persons[0].mood.Items = new BogheCore.Generated.rpid.empty[1];
             * pres.Persons[0].mood.Items[0] = new BogheCore.Generated.rpid.empty();*/

            if (!String.IsNullOrEmpty(this.StatusIconUrl))
            {
                pres.Persons[0].statusicon       = new statusicon();
                pres.Persons[0].statusicon.Value = this.StatusIconUrl;
            }
            if (!String.IsNullOrEmpty(this.HomePage))
            {
                pres.Persons[0].homepage = this.HomePage;
            }

            /*== device ==*/
            pres.Device          = new device();
            pres.Device.id       = String.Format("{0}{1}", "d", "0001");
            pres.Device.deviceID = RCSService.DEVICE_ID;
            pres.Device.Status   = new status();
            pres.Device.Status.basicSpecified                        = true;
            pres.Device.Status.basic                                 = status;
            pres.Device.DeviceCapabilities                           = new BogheCore.Generated.pidf_caps.devcaps();
            pres.Device.DeviceCapabilities.mobility                  = new BogheCore.Generated.pidf_caps.mobilitytype();
            pres.Device.DeviceCapabilities.mobility.supported        = new BogheCore.Generated.pidf_caps.mobilitytypes();
            pres.Device.DeviceCapabilities.mobility.supported.@fixed = String.Empty;
            pres.Device.NetworkAvaibility                            = new networkavailability();
            pres.Device.NetworkAvaibility.network                    = new networkavailabilityNetwork[1];
            pres.Device.NetworkAvaibility.network[0]                 = new networkavailabilityNetwork();
            pres.Device.NetworkAvaibility.network[0].id              = "IMS";
            pres.Device.NetworkAvaibility.network[0].active          = new emptyType();

            return(pres);
        }