Esempio n. 1
0
        private static DataRow crawlRow(DataRow row, out bool isCompanyCrawled)
        {
            DataRow dr = row;

            isCompanyCrawled = false;
            try

            {
                //string t = "Grubstake, Llc";
                //string searchQuery = "http://api.opencorporates.com/v0.4/companies/search?q=" + t.ToString().Replace(' ', '+');
                string searchQuery       = "http://api.opencorporates.com/v0.4/companies/search?q=" + dr[CompanyEnum.COMPANY_NAME].ToString().Replace(' ', '+');
                string companyListString = HTTPUtility.getStringFromUrl(searchQuery);

                var jsonResponse = JsonConvert.DeserializeObject <JsonResponse>(companyListString);
                if (jsonResponse != null && jsonResponse.results.companies.Count > 0)
                {
                    var selectedCompany = jsonResponse.results.companies.FirstOrDefault(c => c.company.inactive == false).company;
                    if (selectedCompany != null)
                    {
                        int _delay = 2;
                        int.TryParse(Delay, out _delay);
                        _delay = _delay == 0 ? 2 * 1000 : _delay * 1000;

                        Thread.Sleep(_delay);
                        string coQuery = "http://api.opencorporates.com/v0.4/companies/" + selectedCompany.jurisdiction_code + "/" + selectedCompany.company_number;

                        string companyResultString = HTTPUtility.getStringFromUrl(coQuery);
                        Thread.Sleep(_delay);
                        var companyResultResponse = JsonConvert.DeserializeObject <JsonResponseCompanyResult>(companyResultString);
                        if (companyResultResponse != null)
                        {
                            var companyData = companyResultResponse.results.company;

                            dr[CompanyEnum.OWNER_F_NAME] = getName(companyData.agent_name, true);
                            dr[CompanyEnum.OWNER_l_NAME] = getName(companyData.agent_name, false);
                            dr[CompanyEnum.OWNER_ADDR]   = companyData.registered_address != null ? companyData.registered_address.street_address : companyData.registered_address_in_full;
                            dr[CompanyEnum.OWNER_CITY]   = companyData.registered_address?.locality ?? "";
                            int z = 0000;
                            int.TryParse(companyData.registered_address?.postal_code, out z);
                            dr[CompanyEnum.OWNER_STATE] = companyData.registered_address?.region ?? "";
                            dr[CompanyEnum.OWNER_ZIP]   = z;
                            string mailDescription = string.IsNullOrEmpty(getMailAddr(companyData)) ? companyData.registered_address_in_full ?? "" : "";
                            dr[CompanyEnum.MAIL_ADDR]  = mailDescription;
                            dr[CompanyEnum.MAIL_UNIT]  = getMailUnits(mailDescription, 1);
                            dr[CompanyEnum.MAIL_CITY]  = getMailUnits(mailDescription, 2);
                            dr[CompanyEnum.MAIL_STATE] = getMailUnits(mailDescription, 3);
                            dr[CompanyEnum.MAIL_ZIP]   = getMailUnits(mailDescription, 4);

                            isCompanyCrawled = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerUtility.Write("Failed to crawl " + row["company name"].ToString(), ex.Message);
                isCompanyCrawled = false;
            }
            return(dr);
        }
Esempio n. 2
0
        public void SendEmail(BusinessTripManagement businessTripManagement, EmailTemplate emailTemplate, EmployeeInfo approver, EmployeeInfo toUser, string webUrl, bool isApprovalLink)
        {
            if (toUser == null || string.IsNullOrEmpty(toUser.Email) || emailTemplate == null || businessTripManagement == null || string.IsNullOrEmpty(webUrl))
            {
                return;
            }
            var content = HTTPUtility.HtmlDecode(emailTemplate.MailBody);

            content = content.Replace("{0}", toUser.FullName);
            if (emailTemplate.MailKey.ToLower() == "businesstripmanagement_approve" || emailTemplate.MailKey.ToLower() == "businesstripmanagement_reject")
            {
                content = content.Replace("{1}", approver.FullName);
                content = content.Replace("{2}", businessTripManagement.Requester.LookupValue);
                content = content.Replace("{3}", businessTripManagement.BusinessTripPurpose);

                string typeOfBusinessTrip = "";
                if (businessTripManagement.Domestic)
                {
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeInternalTitle", StringConstant.ResourcesFileLists, 1033);
                    content            = content.Replace("{4}", typeOfBusinessTrip);
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeInternalTitle", StringConstant.ResourcesFileLists, 1066);
                    content            = content.Replace("{5}", typeOfBusinessTrip);
                }
                else
                {
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeExternalTitle", StringConstant.ResourcesFileLists, 1033);
                    content            = content.Replace("{4}", typeOfBusinessTrip);
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeExternalTitle", StringConstant.ResourcesFileLists, 1066);
                    content            = content.Replace("{5}", typeOfBusinessTrip);
                }
            }
            else
            {
                content = content.Replace("{1}", businessTripManagement.Requester.LookupValue);
                content = content.Replace("{2}", businessTripManagement.BusinessTripPurpose);

                string typeOfBusinessTrip = "";
                if (businessTripManagement.Domestic)
                {
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeInternalTitle", StringConstant.ResourcesFileLists, 1033);
                    content            = content.Replace("{3}", typeOfBusinessTrip);
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeInternalTitle", StringConstant.ResourcesFileLists, 1066);
                    content            = content.Replace("{4}", typeOfBusinessTrip);
                }
                else
                {
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeExternalTitle", StringConstant.ResourcesFileLists, 1033);
                    content            = content.Replace("{3}", typeOfBusinessTrip);
                    typeOfBusinessTrip = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeExternalTitle", StringConstant.ResourcesFileLists, 1066);
                    content            = content.Replace("{4}", typeOfBusinessTrip);
                }
            }

            var link = GetEmailLinkByUserPosition(webUrl, toUser.EmployeePosition.LookupId, businessTripManagement.ID, isApprovalLink);

            content = content.Replace("#link", link);
            SendEmailActivity sendMailActivity = new SendEmailActivity();

            sendMailActivity.SendMail(webUrl, emailTemplate.MailSubject, toUser.Email, true, false, content);
        }
Esempio n. 3
0
 public void initializeVKApi(string key = "")
 {
     if (!String.IsNullOrEmpty(key))
     {
         privateKey = key;
     }
     if (initialized)
     {
         Debug2.LogWarning("vk api already initialized, init method will be ignored");
     }
     else
     {
         initialized  = true;
         callbackPool = CallbackPool.instance;
         callbackPool.initialize();
         initVKApi(privateKey,
                   delegate(object obj, Callback callback){
             inputData = HTTPUtility.ParseQueryString((string)obj);
             Debug2.LogDebug("viewer id =" + inputData["viewer_id"]);
             callbackPool.releaseDisposableCallback(callbackOnInitError);
             if (onApiReady != null)
             {
                 onApiReady(true);
             }
             Debug2.LogDebug("VK api is ready");
         },
                   delegate(object obj, Callback callback){
             onApiReady(false);
             callbackPool.releaseDisposableCallback(callBackOnInitDone);
             Debug2.LogError("problem with vk initialization\n" + Json.Serialize(obj));
         });
     }
 }
Esempio n. 4
0
        public void SendDelegationEmail(VehicleManagement model, EmailTemplate EmailTempalte, List <EmployeeInfo> toUsers, string webUrl)
        {
            var link       = string.Format(@"{0}/Lists/VehicleManagement/EditForm.aspx?subSection=TransportationManagement&ID={1}&Source=/_layouts/15/RBVH.Stada.Intranet.WebPages/DelegationManagement/DelegationList.aspx&Source=Tab=DelegationsApprovalTab", webUrl, model.ID);
            var department = DepartmentListSingleton.GetDepartmentByID(model.CommonDepartment.LookupId, this.SiteUrl);

            SendEmailActivity sendMailActivity = new SendEmailActivity();

            if (toUsers != null)
            {
                foreach (var toUser in toUsers)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(toUser.Email))
                        {
                            var content = HTTPUtility.HtmlDecode(EmailTempalte.MailBody);
                            content = content.Replace("{0}", toUser.FullName);
                            content = content.Replace("{1}", model.Requester.LookupValue);
                            content = content.Replace("{2}", model.From.ToString("dd/MM/yyy hh:mm"));
                            content = content.Replace("{3}", model.ToDate.ToString("dd/MM/yyy hh:mm"));
                            content = content.Replace("{4}", department.Name);
                            content = content.Replace("{5}", department.VietnameseName);
                            content = content.Replace("#link", link);
                            sendMailActivity.SendMail(webUrl, EmailTempalte.MailSubject, toUser.Email, true, false, content);
                        }
                    }
                    catch { }
                }
            }
        }
Esempio n. 5
0
        private List <Item> GetItems(byte[] data, ref string source)
        {
            var    items     = new List <Item>();
            string contentId = FileList.GetContentId(data);
            var    files     = FileList.GetFileList(contentId, "content_id");

            if (files.Count > 0)
            {
                string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, "content_id", contentId);
                if (files.Count > 1)
                {
                    source = HTTPUtility.GetRequest(stream);
                }
                else
                {
                    string name = Path.GetFileName(files.First().Value);
                    var    item = new Item()
                    {
                        Name = Path.GetFileName(name),
                        Link = stream,
                        Type = ItemType.FILE
                    };
                    items.Add(item);
                }
            }

            return(items);
        }
Esempio n. 6
0
        private async void buttonUpload_Click(object sender, EventArgs e)
        {
            if (
                FormImageUploadValidator.ValidRequiredTextBoxFields(errorProvider, textBoxRequestNumber, textBoxUserName) &&
                FormImageUploadValidator.ValidateFileInputField(errorProvider, openFileDialog, buttonAddFile) &&
                FormImageUploadValidator.ValidateRequestNumber(errorProvider, textBoxRequestNumber)
                )
            {
                disableAllButtons();

                var response = await HTTPUtility.PostData(
                    ConfigurationManager.AppSettings["SurityRestAPIBaseURL"] + ConfigurationManager.AppSettings["ImageUploadEndpoint"],
                    new
                {
                    RequestNumber = textBoxRequestNumber.Text,
                    UserName      = textBoxUserName.Text,
                    ImageName     = openFileDialog.SafeFileName,
                    ImageData     = File.ReadAllBytes(openFileDialog.FileName)
                }
                    );

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    errorProvider.SetError(buttonUpload, string.Empty);
                    showUploadSuccessText();
                }
                else
                {
                    errorProvider.SetError(buttonUpload, await response.Content.ReadAsStringAsync());
                    labelUploadSuccess.Text = string.Empty;
                }

                enableAllButtons();
            }
        }
Esempio n. 7
0
        public override async Task <string> Handle(HttpRequest request, HttpResponse response)
        {
            string userAgent = request.Headers["User-Agent"].ToString();
            var    headers   = new Dictionary <string, string> {
                { "User-Agent", userAgent }
            };

            string script =
                await HTTPUtility.GetRequestAsync("http://getlist5.obovse.ru/jsapp/app.js.php?run=js", headers);

            string path     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot", "forkplayer");
            string filePath = Path.Combine(path, "forkplayer.js");

            if (string.IsNullOrEmpty(script) || script.Length < 1024)
            {
                if (File.Exists(filePath))
                {
                    script = await File.ReadAllTextAsync(filePath);
                }
            }
            else
            {
                CreateDirectoryRecursively(path);
                using (var outputFile = new StreamWriter(filePath, false)) {
                    await outputFile.WriteAsync(script);
                }
            }

            return(script);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="notOvertimeItemId"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        /// CALL URL: /_vti_bin/Services/Email/EmailService.svc/SendNotOvertimeRequestResultEmail/1/Approve
        public bool SendNotOvertimeRequestResultEmail(string notOvertimeItemId, string result)
        {
            try
            {
                int idValue;
                if (int.TryParse(notOvertimeItemId, out idValue))
                {
                    string key = string.Empty;
                    if (result.Equals("Approve"))
                    {
                        key = "LOAbsence_Approve";
                    }
                    else if (result.Equals("Reject"))
                    {
                        key = "LOAbsence_Reject";
                    }
                    if (!string.IsNullOrEmpty(key))
                    {
                        var notOvertimeRequestMailItem = _emailTemplateDAL.GetByKey(key);
                        var notOvertimeManagementItem  = _notOvertimeMangementDAL.GetByID(idValue);

                        if (notOvertimeRequestMailItem != null && notOvertimeManagementItem != null)
                        {
                            var employee = _employeeDAL.GetByID(notOvertimeManagementItem.Requester.LookupId);

                            if (employee != null && !string.IsNullOrEmpty(employee.Email))
                            {
                                string emailBody = HTTPUtility.HtmlDecode(notOvertimeRequestMailItem.MailBody);

                                //lookup email
                                string link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceMember}";
                                if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.Administrator)
                                {
                                    link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceAdmin}";
                                }
                                if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.DepartmentHead)
                                {
                                    link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceManager}";
                                }
                                emailBody = string.Format(emailBody, employee.FullName, notOvertimeManagementItem.Requester.LookupValue,
                                                          notOvertimeManagementItem.Date.ToString(StringConstant.DateFormatddMMyyyy2),
                                                          notOvertimeManagementItem.Reason, notOvertimeManagementItem.Comment);
                                emailBody = emailBody.Replace("#link", link);
                                _sendMailActivity.SendMail(SPContext.Current.Web.Url, notOvertimeRequestMailItem.MailSubject, employee.Email, true, false, emailBody);
                                return(true);
                            }
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendNotOvertimeRequestResultEmail fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(false);
            }
        }
        /// <summary>
        /// Send email to Requester after
        /// </summary>
        /// <param name="changeshiftItemId"></param>
        /// <returns></returns>
        /// CALL URL: /_vti_bin/Services/Email/EmailService.svc/SendChangeShiftRequestMail/1/BOD
        public bool SendChangeShiftRequestMail(string changeshiftItemId, string toRole)
        {
            try
            {
                int idValue;
                if (int.TryParse(changeshiftItemId, out idValue))
                {
                    var changeShiftManagementItem  = _changeShiftManagementDAL.GetByID(idValue);
                    var changeshiftRequestMailItem = _emailTemplateDAL.GetByKey("ChangeShift_Request");
                    if (changeshiftRequestMailItem != null && changeShiftManagementItem != null)
                    {
                        string email            = string.Empty;
                        string employeeFullname = string.Empty;
                        string link             = string.Empty;
                        if (toRole.Equals("DH"))
                        {
                            var accountDHItem = _employeeDAL.GetByADAccount(changeShiftManagementItem.DepartmentHead.ID);
                            email            = accountDHItem.Email;
                            employeeFullname = accountDHItem.FullName;
                            link             = $"{WebUrl}/{StringConstant.WebPageLinks.ChangeShiftManager}";
                        }
                        else if (toRole.Equals("BOD"))
                        {
                            var accountBODItem = _employeeDAL.GetByADAccount(changeShiftManagementItem.BOD.ID);
                            email            = accountBODItem.Email;
                            employeeFullname = accountBODItem.FullName;
                            link             = $"{WebUrl}/{StringConstant.WebPageLinks.ChangeShiftBOD}";
                        }

                        if (!string.IsNullOrEmpty(email))
                        {
                            var shiftTimeList = _shiftTimeDAL.GetShiftTimes();

                            string emailBody = HTTPUtility.HtmlDecode(changeshiftRequestMailItem.MailBody);
                            //lookup email
                            var fromShiftItem = shiftTimeList.Where(x => x.ID == changeShiftManagementItem.FromShift.LookupId).FirstOrDefault();
                            var toShiftItem   = shiftTimeList.Where(x => x.ID == changeShiftManagementItem.ToShift.LookupId).FirstOrDefault();

                            emailBody = string.Format(emailBody, employeeFullname, changeShiftManagementItem.Requester.LookupValue,
                                                      changeShiftManagementItem.FromDate.ToString(StringConstant.DateFormatddMMyyyy2),
                                                      changeShiftManagementItem.ToDate.ToString(StringConstant.DateFormatddMMyyyy2),
                                                      changeShiftManagementItem.Reason, fromShiftItem.Code, toShiftItem.Code);

                            emailBody = emailBody.Replace("#link", link);
                            _sendMailActivity.SendMail(SPContext.Current.Web.Url, changeshiftRequestMailItem.MailSubject, email, true, false, emailBody);
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendChangeShiftRequestMail fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(false);
            }
        }
Esempio n. 10
0
        public static void PostModel(SettingsModel settings)
        {
            if (!string.IsNullOrEmpty(settings.IP))
            {
                ProgramSettings.Settings.IpAddress = settings.IP;

                if (!string.IsNullOrEmpty(settings.UserAgent))
                {
                    ProgramSettings.Settings.UserAgent = settings.UserAgent;
                }

                ProgramSettings.Settings.ListenLocalhost = settings.ListenLocalhost;

                ProgramSettings.Settings.CheckUpdate   = settings.CheckUpdate;
                ProgramSettings.Settings.DeveloperMode = settings.DeveloperMode;

                if (!string.IsNullOrEmpty(settings.ProxyType))
                {
                    Enum.TryParse(settings.ProxyType, out ProxyType value);
                    if (ProgramSettings.Settings.ProxyType != value)
                    {
                        ProgramSettings.Settings.ProxyType = value;
                    }
                }

                ProgramSettings.Settings.UseProxy              = settings.ProxyEnable;
                ProgramSettings.Settings.ProxyAddress          = settings.ProxyAddress;
                ProgramSettings.Settings.ProxyPort             = settings.ProxyPort;
                ProgramSettings.Settings.ProxyUserName         = settings.ProxyUserName;
                ProgramSettings.Settings.ProxyPassword         = settings.ProxyPassword;
                ProgramSettings.Settings.ProxyNotDefaultEnable = settings.ProxyNotDefaultEnable;

                if (settings.ProxyEnable)
                {
                    HTTPUtility.CreateProxy(ProgramSettings.Settings.ProxyAddress, ProgramSettings.Settings.ProxyPort,
                                            ProgramSettings.Settings.ProxyUserName, ProgramSettings.Settings.ProxyPassword);
                }
                else
                {
                    HTTPUtility.CreateProxy();
                }
            }

            if (ProgramSettings.Settings.AceStreamPort != settings.AceStreamPort)
            {
                ProgramSettings.Settings.AceStreamPort = settings.AceStreamPort;
            }

            if (!string.IsNullOrEmpty(settings.Log))
            {
                byte.TryParse(settings.Log, out byte value);
                if (ProgramSettings.Settings.LogLevel != value)
                {
                    ProgramSettings.Settings.LogLevel = value;
                }
            }

            ProgramSettings.Instance.Save();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="notOvertimeItemId"></param>
        /// <param name="toRole"></param>
        /// <returns></returns>
        /// CALL URL: : /_vti_bin/Services/Email/EmailService.svc/SendNotovertimeRequestRequestEmail/1/BOD
        public bool SendNotOverTimeRequestEmail(string notOvertimeItemId, string toRole)
        {
            try
            {
                int idValue;
                if (int.TryParse(notOvertimeItemId, out idValue))
                {
                    var notOvertimeManagementItem  = _notOvertimeMangementDAL.GetByID(idValue);
                    var notOvertimeRequestMailItem = _emailTemplateDAL.GetByKey("LOAbsence_Request");
                    if (notOvertimeRequestMailItem != null && notOvertimeManagementItem != null)
                    {
                        string link              = string.Empty;
                        string email             = string.Empty;
                        string empployeeFullname = string.Empty;
                        if (toRole.Equals("DH"))
                        {
                            if (notOvertimeManagementItem.DH != null)
                            {
                                var accountDHItem = _employeeDAL.GetByADAccount(notOvertimeManagementItem.DH.ID);
                                email             = accountDHItem.Email;
                                empployeeFullname = accountDHItem.FullName;
                                link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceManager}#tab2";
                            }
                        }
                        else if (toRole.Equals("BOD"))
                        {
                            if (notOvertimeManagementItem.DH != null)
                            {
                                var accountBODItem = _employeeDAL.GetByADAccount(notOvertimeManagementItem.DH.ID);
                                email             = accountBODItem.Email;
                                empployeeFullname = accountBODItem.FullName;
                                link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceBOD}#tab2";
                            }
                        }

                        if (!string.IsNullOrEmpty(email))
                        {
                            string emailBody = HTTPUtility.HtmlDecode(notOvertimeRequestMailItem.MailBody);
                            //lookup email
                            emailBody = string.Format(emailBody, empployeeFullname, notOvertimeManagementItem.Requester.LookupValue,
                                                      notOvertimeManagementItem.Date.ToString(StringConstant.DateFormatddMMyyyy2),
                                                      notOvertimeManagementItem.Reason);
                            emailBody = emailBody.Replace("#link", link);
                            _sendMailActivity.SendMail(SPContext.Current.Web.Url, notOvertimeRequestMailItem.MailSubject, email, true, false, emailBody);
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendNotOverTimeRequestEmail fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(false);
            }
        }
        //public override void ItemUpdated(SPItemEventProperties properties)
        //{
        //    base.ItemUpdated(properties);
        //    try
        //    {
        //        //_employeeInfoDAL = new EmployeeInfoDAL(properties.WebUrl);
        //        //var itemId = properties.ListItem.ID;
        //        //string modifiedByName = string.Empty;
        //        //var modifiedByString = Convert.ToString(properties.ListItem["Modified By"]);
        //        //SPFieldUser spUserField = (SPFieldUser)properties.ListItem.Fields.GetField("Modified By");
        //        //if (spUserField != null)
        //        //{
        //        //    SPFieldUserValue spNewUserFieldValue = (SPFieldUserValue)spUserField.GetFieldValue(modifiedByString);
        //        //    SPUser spModifiedByUser = properties.Web.EnsureUser(spNewUserFieldValue.LookupValue);
        //        //    var modifiedBy = _employeeInfoDAL.GetByADAccount(spModifiedByUser.ID);
        //        //    modifiedByName = modifiedBy != null ? modifiedBy.FullName : string.Empty;
        //        //}

        //        //SendEmailToApprover(properties.Web, itemId, modifiedByName);
        //    }
        //    catch (Exception ex)
        //    {
        //        ULSLogging.Log(new SPDiagnosticsCategory("STADA -  Shift Management Event Receiver - ItemUpdated fn",
        //            TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
        //        string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
        //    }
        //}

        private void SendEmailToApprover(SPWeb web, int itemId, string modifiedBy = "")
        {
            EmployeeInfoDAL    employeeInfoDAL    = new EmployeeInfoDAL(web.Url);
            EmailTemplateDAL   emailTemplateDAL   = new EmailTemplateDAL(web.Url);
            ShiftManagementDAL shiftManagementDAL = new ShiftManagementDAL(web.Url);

            var shiftManagementItem = shiftManagementDAL.GetByID(itemId);

            if (shiftManagementItem != null)
            {
                SPUser departmentHeadSPUser = web.EnsureUser(shiftManagementItem.ApprovedBy.UserName);

                var departmentHead = employeeInfoDAL.GetByADAccount(departmentHeadSPUser.ID);
                if (departmentHead != null)
                {
                    var requestEmailItem = emailTemplateDAL.GetByKey("ShiftManagement_Request");
                    if (requestEmailItem != null)
                    {
                        string emailBody = HTTPUtility.HtmlDecode(requestEmailItem.MailBody);
                        if (!string.IsNullOrEmpty(departmentHead.Email) && !string.IsNullOrEmpty(emailBody))
                        {
                            string link       = string.Format("{0}/SitePages/ShiftApproval.aspx?itemId={1}&Source={0}/_layouts/15/RBVH.Stada.Intranet.WebPages/ShiftManagement/ShiftManagementManager.aspx", web.Url, shiftManagementItem.ID);
                            var    department = DepartmentListSingleton.GetDepartmentByID(shiftManagementItem.Department.LookupId, web.Url);
                            emailBody = string.Format(emailBody, departmentHead.FullName, string.IsNullOrEmpty(modifiedBy) ? shiftManagementItem.Requester.LookupValue : modifiedBy, shiftManagementItem.Month,
                                                      shiftManagementItem.Year, shiftManagementItem.Department.LookupValue, department.VietnameseName);

                            emailBody = emailBody.Replace("#link", link);
                            _sendMailActivity.SendMail(web.Url, requestEmailItem.MailSubject, departmentHead.Email, true, false, emailBody);

                            List <EmployeeInfo> toUsers = DelegationPermissionManager.GetListOfDelegatedEmployees(web.Url, departmentHead.ID, StringConstant.ShiftManagementList.ListUrl, shiftManagementItem.ID);
                            link = string.Format("{0}/SitePages/ShiftApproval.aspx?subSection=ShiftManagement&itemId={1}&Source=/_layouts/15/RBVH.Stada.Intranet.WebPages/DelegationManagement/DelegationList.aspx&Source=Tab=DelegationsApprovalTab", web.Url, shiftManagementItem.ID);
                            if (toUsers != null)
                            {
                                foreach (var toUser in toUsers)
                                {
                                    try
                                    {
                                        if (!string.IsNullOrEmpty(toUser.Email))
                                        {
                                            emailBody = HTTPUtility.HtmlDecode(requestEmailItem.MailBody);
                                            emailBody = string.Format(emailBody, toUser.FullName, string.IsNullOrEmpty(modifiedBy) ? shiftManagementItem.Requester.LookupValue : modifiedBy, shiftManagementItem.Month,
                                                                      shiftManagementItem.Year, shiftManagementItem.Department.LookupValue, department.VietnameseName);
                                            emailBody = emailBody.Replace("#link", link);
                                            _sendMailActivity.SendMail(web.Url, requestEmailItem.MailSubject, toUser.Email, true, false, emailBody);
                                        }
                                    }
                                    catch { }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 13
0
        public static string GetContentId(string torrentData)
        {
            string response = HTTPUtility.PostRequest("http://api.torrentstream.net/upload/raw",
                                                      Encoding.UTF8.GetBytes(torrentData));
            var content = JsonConvert.DeserializeObject <TorrentId>(response);

            if (string.IsNullOrEmpty(content.Error))
            {
                return(content.ContentID);
            }
            return(response);
        }
Esempio n. 14
0
        public IObservable <JObject> Request(String url, Func <HttpWebRequest, HttpWebRequest> requestModifier)
        {
            IObservable <WebResponse> response = CreateResponse(CreateRequest(url, requestModifier));

            return(response.SelectMany
                   (
                       r => ReponseToObservable <JObject, JObject>
                       (
                           r,
                           s => JObject.Parse(HTTPUtility.Decode(r, s).Replace("\\x", "\\u00")), // JSON.net does not support hexadecimal escapes.
                           x => Observable.Return(x)
                       )
                   ));
        }
        public bool SendDelegationNotOverTimeRequestEmail(string notOvertimeItemId, string toRole)
        {
            try
            {
                int idValue;
                if (int.TryParse(notOvertimeItemId, out idValue))
                {
                    var notOvertimeManagementItem  = _notOvertimeMangementDAL.GetByID(idValue);
                    var notOvertimeRequestMailItem = _emailTemplateDAL.GetByKey("LOAbsence_Request");
                    if (notOvertimeRequestMailItem != null && notOvertimeManagementItem != null)
                    {
                        var    siteUrl = SPContext.Current.Site.Url;
                        string link    = string.Format(@"{0}/_layouts/15/RBVH.Stada.Intranet.WebPages/LeaveOfAbsenceManagement/LeaveOfAbsenceApprovalDelegation.aspx?itemId={1}&Source=/_layouts/15/RBVH.Stada.Intranet.WebPages/DelegationManagement/DelegationList.aspx&Source=Tab=DelegationsApprovalTab", siteUrl, notOvertimeManagementItem.ID);

                        var dhUser = _employeeDAL.GetByADAccount(notOvertimeManagementItem.DH.ID);
                        List <EmployeeInfo> toUsers = DelegationPermissionManager.GetListOfDelegatedEmployees(siteUrl, dhUser.ID, StringConstant.NotOvertimeList.ListUrl, notOvertimeManagementItem.ID);

                        if (toUsers != null)
                        {
                            foreach (var toUser in toUsers)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(toUser.Email))
                                    {
                                        string emailBody = HTTPUtility.HtmlDecode(notOvertimeRequestMailItem.MailBody);
                                        emailBody = string.Format(emailBody, toUser.FullName, notOvertimeManagementItem.Requester.LookupValue,
                                                                  notOvertimeManagementItem.Date.ToString(StringConstant.DateFormatddMMyyyy2),
                                                                  notOvertimeManagementItem.Reason);
                                        emailBody = emailBody.Replace("#link", link);
                                        _sendMailActivity.SendMail(SPContext.Current.Web.Url, notOvertimeRequestMailItem.MailSubject, toUser.Email, true, false, emailBody);
                                    }
                                }
                                catch { }
                            }
                        }

                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendDelegationNotOverTimeRequestEmail fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(false);
            }
        }
Esempio n. 16
0
        public async Task <string> CurlRequest(string text)
        {
            string result;

            if (text.StartsWith("curlorig"))
            {
                Log.LogDebug("curlorig " + text.Substring(9));

                result = await HTTPUtility.GetRequestAsync(text.Substring(9));
            }
            else
            {
                bool verbose      = text.IndexOf(" -i", StringComparison.Ordinal) > 0;
                bool autoredirect = text.IndexOf(" -L", StringComparison.Ordinal) > 0;

                string url     = Regex.Match(text, "(?:\")(.*?)(?=\")").Groups[1].Value;
                var    matches = Regex.Matches(text, "(?:-H\\s\")(.*?)(?=\")");
                var    header  = (
                    from Match match in matches
                    select match.Groups
                    into groups
                    where groups.Count > 1
                    select groups[1].Value
                    into value
                    where value.Contains(": ")
                    select value).ToDictionary(value => value.Remove(value.IndexOf(": ", StringComparison.Ordinal)),
                                               value => value.Substring(value.IndexOf(": ", StringComparison.Ordinal) + 2));
                if (text.Contains("--data"))
                {
                    Log.LogDebug("POST DATA");
                    try {
                        string dataString = Regex.Match(text, "(?:--data\\s\")(.*?)(?=\")").Groups[1].Value;
                        result = await HTTPUtility.PostRequestAsync(url, dataString, header, verbose, autoredirect);
                    } catch (Exception e) {
                        result = e.ToString();
                        Log.LogDebug(e.ToString());
                    }
                }
                else
                {
                    Log.LogInformation(url);

                    result = await HTTPUtility.GetRequestAsync(url, header, verbose, autoredirect);
                }
            }

            return(result);
        }
        private void SendEmail(string webUrl, int changeshiftItemId, string emailKey, string approverFullName)
        {
            SendEmailActivity sendMailActity = new SendEmailActivity();

            Thread thread = new Thread(delegate()
            {
                var _emailTemplateDAL          = new EmailTemplateDAL(webUrl);
                var _employeeDAL               = new EmployeeInfoDAL(webUrl);
                var _shiftTimeDAL              = new ShiftTimeDAL(webUrl);
                var _sendMailActivity          = new SendEmailActivity();
                var changeShiftManagementItem  = _changeShiftManagementDAL.GetByID(changeshiftItemId);
                var changeshiftRequestMailItem = _emailTemplateDAL.GetByKey(emailKey);
                if (changeshiftRequestMailItem != null && changeShiftManagementItem != null)
                {
                    var employee = _employeeDAL.GetByID(changeShiftManagementItem.Requester.LookupId);

                    if (employee != null && !string.IsNullOrEmpty(employee.Email))
                    {
                        var shiftTimeList = _shiftTimeDAL.GetShiftTimes();
                        string emailBody  = HTTPUtility.HtmlDecode(changeshiftRequestMailItem.MailBody);

                        var fromShiftItem = shiftTimeList.Where(x => x.ID == changeShiftManagementItem.FromShift.LookupId).FirstOrDefault();
                        var toShiftItem   = shiftTimeList.Where(x => x.ID == changeShiftManagementItem.ToShift.LookupId).FirstOrDefault();
                        //lookup email
                        string link = $"{webUrl}/{StringConstant.WebPageLinks.ChangeShiftMember}";
                        if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.Administrator)
                        {
                            link = $"{webUrl}/{StringConstant.WebPageLinks.ChangeShiftAdmin}";
                        }
                        if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.DepartmentHead)
                        {
                            link = $"{webUrl}/{StringConstant.WebPageLinks.ChangeShiftManager}";
                        }

                        emailBody = string.Format(emailBody, employee.FullName, changeShiftManagementItem.Requester.LookupValue,
                                                  changeShiftManagementItem.FromDate.ToString(StringConstant.DateFormatddMMyyyy2),
                                                  changeShiftManagementItem.ToDate.ToString(StringConstant.DateFormatddMMyyyy2),
                                                  changeShiftManagementItem.Reason, fromShiftItem.Code, toShiftItem.Code, changeShiftManagementItem.Comment, approverFullName);
                        emailBody = emailBody.Replace("#link", link);
                        _sendMailActivity.SendMail(webUrl, changeshiftRequestMailItem.MailSubject, employee.Email, true, false, emailBody);
                    }
                }
            });

            thread.IsBackground = true;
            thread.Start();
        }
Esempio n. 18
0
        public static Dictionary <string, string> GetFileList(string key, string type)
        {
            string aceMadiaInfo =
                HTTPUtility.GetRequest(string.Format("{0}/server/api?method=get_media_files&{1}={2}",
                                                     AceStreamEngine.GetServer, type, key));

            if (!string.IsNullOrWhiteSpace(aceMadiaInfo))
            {
                var files = JsonConvert.DeserializeObject <TorrentFile>(aceMadiaInfo);
                if (string.IsNullOrEmpty(files.Error))
                {
                    return(files.Result);
                }
            }

            return(new Dictionary <string, string>());
        }
Esempio n. 19
0
        public void SendDelegationEmail(BusinessTripManagement businessTripManagement, EmailTemplate emailTemplate, List <EmployeeInfo> toUsers, string webUrl)
        {
            if (toUsers == null || toUsers.Count == 0 || emailTemplate == null || businessTripManagement == null || string.IsNullOrEmpty(webUrl))
            {
                return;
            }

            string typeOfBusinessTripEN = "";
            string typeOfBusinessTripVN = "";

            if (businessTripManagement.Domestic)
            {
                typeOfBusinessTripEN = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeInternalTitle", StringConstant.ResourcesFileLists, 1033);
                typeOfBusinessTripVN = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeInternalTitle", StringConstant.ResourcesFileLists, 1066);
            }
            else
            {
                typeOfBusinessTripEN = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeExternalTitle", StringConstant.ResourcesFileLists, 1033);
                typeOfBusinessTripVN = ResourceHelper.GetLocalizedString("BusinessTripManagement_BusinessTripTypeExternalTitle", StringConstant.ResourcesFileLists, 1066);
            }
            var link = string.Format(@"{0}/SitePages/BusinessTripRequest.aspx?subSection=BusinessTripManagement&itemId={1}&Source=/_layouts/15/RBVH.Stada.Intranet.WebPages/DelegationManagement/DelegationList.aspx&Source=Tab=DelegationsApprovalTab", webUrl, businessTripManagement.ID);
            SendEmailActivity sendMailActivity = new SendEmailActivity();

            foreach (var toUser in toUsers)
            {
                try
                {
                    if (!string.IsNullOrEmpty(toUser.Email))
                    {
                        var content = HTTPUtility.HtmlDecode(emailTemplate.MailBody);

                        content = content.Replace("{0}", toUser.FullName);
                        content = content.Replace("{1}", businessTripManagement.Requester.LookupValue);
                        content = content.Replace("{2}", businessTripManagement.BusinessTripPurpose);

                        content = content.Replace("{3}", typeOfBusinessTripEN);
                        content = content.Replace("{4}", typeOfBusinessTripVN);

                        content = content.Replace("#link", link);
                        sendMailActivity.SendMail(webUrl, emailTemplate.MailSubject, toUser.Email, true, false, content);
                    }
                }
                catch { }
            }
        }
Esempio n. 20
0
        public override async Task <string> Handle(HttpRequest request, HttpResponse response)
        {
            try {
                string url = HttpUtility.UrlDecode(request.QueryString.Value);
                if (request.Method == "POST")
                {
                    using (var readStream = new StreamReader(request.Body, Encoding.UTF8)) {
                        url = readStream.ReadToEnd();
                    }
                }

                if (url.StartsWith("s=B"))
                {
                    url = url.Substring(3);

                    string contentId = FileList.GetContentId(url);
                    return(await GetFileList(FileList.GetFileList(contentId, "content_id"), contentId, "content_id"));
                }
                else if (url.StartsWith("torrenturl="))
                {
                    url = url.Substring(11);
                    url = HttpUtility.UrlDecode(url);
                    if (url.StartsWith("torrent://"))
                    {
                        url = url.Substring(10);
                    }

                    var data = await HTTPUtility.GetBytesRequestAsync(url);

                    string contentId = FileList.GetContentId(data);
                    return(await GetFileList(FileList.GetFileList(contentId, "content_id"), contentId, "content_id"));
                }
                else if (url.StartsWith("magnet="))
                {
                    url = url.Substring(7);

                    return(await GetFileList(FileList.GetFileList(url, "magnet"), url, "magnet"));
                }

                return(string.Empty);
            } catch (Exception exception) {
                Log.LogError(exception);
                return(exception.Message);
            }
        }
Esempio n. 21
0
        public void SendEmail(FreightManagement freightManagementItem, EmailTemplate emailTemplate, EmployeeInfo approver, EmployeeInfo toUser, string webUrl, bool isApprovalLink)
        {
            if (toUser == null || string.IsNullOrEmpty(toUser.Email) || emailTemplate == null || freightManagementItem == null || string.IsNullOrEmpty(webUrl))
            {
                return;
            }
            var content = HTTPUtility.HtmlDecode(emailTemplate.MailBody);

            var bringerName             = string.Empty;
            var bringerNameInVietnamese = string.Empty;

            if (freightManagementItem.CompanyVehicle)
            {
                bringerName             = ResourceHelper.GetLocalizedString("FreightRequest_CompanyVehicle", StringConstant.ResourcesFileWebPages, 1033);
                bringerNameInVietnamese = ResourceHelper.GetLocalizedString("FreightRequest_CompanyVehicle", StringConstant.ResourcesFileWebPages, 1066);
            }
            else
            {
                bringerName = bringerNameInVietnamese = freightManagementItem.Bringer.LookupId > 0 ? freightManagementItem.Bringer.LookupValue : freightManagementItem.BringerName;
            }

            if (emailTemplate.MailKey.ToLower() == "freightmanagement_approve" || emailTemplate.MailKey.ToLower() == "freightmanagement_reject")
            {
                content = content.Replace("{0}", toUser.FullName);
                content = content.Replace("{1}", approver.FullName);
                content = content.Replace("{2}", freightManagementItem.Requester.LookupValue);
                content = content.Replace("{3}", bringerName);
                content = content.Replace("{4}", freightManagementItem.Receiver);
                content = content.Replace("{5}", bringerNameInVietnamese);
            }
            else
            {
                content = content.Replace("{0}", toUser.FullName);
                content = content.Replace("{1}", freightManagementItem.Requester.LookupValue);
                content = content.Replace("{2}", bringerName);
                content = content.Replace("{3}", freightManagementItem.Receiver);
                content = content.Replace("{4}", bringerNameInVietnamese);
            }
            var link = GetEmailLinkByUserPosition(webUrl, toUser.EmployeePosition.LookupId, freightManagementItem.ID, isApprovalLink);

            content = content.Replace("#link", link);
            SendEmailActivity sendMailActivity = new SendEmailActivity();

            sendMailActivity.SendMail(webUrl, emailTemplate.MailSubject, toUser.Email, true, false, content);
        }
Esempio n. 22
0
        public string GetFileList(Dictionary <string, string> files, string key, string type)
        {
            var items = new List <Item>();

            if (files.Count > 0)
            {
                if (files.Count > 1)
                {
                    string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, type, key);
                    return(HTTPUtility.GetRequest(stream));
                }
                else
                {
                    string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, type, key);
                    string name   = Path.GetFileName(files.First().Value);
                    var    item   = new Item()
                    {
                        Name      = Path.GetFileName(name),
                        ImageLink = "http://obovse.ru/ForkPlayer2.5/img/file.png",
                        Link      = stream,
                        Type      = ItemType.FILE
                    };
                    items.Add(item);

                    stream = string.Format("{0}/ace/manifest.m3u8?{1}={2}", AceStreamEngine.GetServer, type, key);
                    item   = new Item()
                    {
                        Name      = "(hls) " + Path.GetFileName(name),
                        ImageLink = "http://obovse.ru/ForkPlayer2.5/img/file.png",
                        Link      = stream,
                        Type      = ItemType.FILE
                    };
                    items.Add(item);
                }
            }

            var playlist = new Playlist {
                Items  = items.ToArray(),
                IsIptv = "false"
            };

            return(ResponseSerializer.PlaylistToXml(playlist));
        }
Esempio n. 23
0
        public void SendDelegationEmail(FreightManagement freightManagementItem, EmailTemplate emailTemplate, List <EmployeeInfo> toUsers, string webUrl)
        {
            if (toUsers == null || toUsers.Count == 0 || emailTemplate == null || freightManagementItem == null || string.IsNullOrEmpty(webUrl))
            {
                return;
            }

            SendEmailActivity sendMailActivity = new SendEmailActivity();
            var link = string.Format(@"{0}/SitePages/FreightRequest.aspx?subSection=FreightManagement&itemId={1}&Source=/_layouts/15/RBVH.Stada.Intranet.WebPages/DelegationManagement/DelegationList.aspx&Source=Tab=DelegationsApprovalTab", webUrl, freightManagementItem.ID);

            foreach (var toUser in toUsers)
            {
                try
                {
                    if (!string.IsNullOrEmpty(toUser.Email))
                    {
                        var content = HTTPUtility.HtmlDecode(emailTemplate.MailBody);

                        var bringerName             = string.Empty;
                        var bringerNameInVietnamese = string.Empty;
                        if (freightManagementItem.CompanyVehicle)
                        {
                            bringerName             = ResourceHelper.GetLocalizedString("FreightRequest_CompanyVehicle", StringConstant.ResourcesFileWebPages, 1033);
                            bringerNameInVietnamese = ResourceHelper.GetLocalizedString("FreightRequest_CompanyVehicle", StringConstant.ResourcesFileWebPages, 1066);
                        }
                        else
                        {
                            bringerName = bringerNameInVietnamese = freightManagementItem.Bringer.LookupId > 0 ? freightManagementItem.Bringer.LookupValue : freightManagementItem.BringerName;
                        }

                        content = content.Replace("{0}", toUser.FullName);
                        content = content.Replace("{1}", freightManagementItem.Requester.LookupValue);
                        content = content.Replace("{2}", bringerName);
                        content = content.Replace("{3}", freightManagementItem.Receiver);
                        content = content.Replace("{4}", bringerNameInVietnamese);
                        content = content.Replace("#link", link);
                        sendMailActivity.SendMail(webUrl, emailTemplate.MailSubject, toUser.Email, true, false, content);
                    }
                }
                catch { }
            }
        }
Esempio n. 24
0
        private void TestBots()
        {
            foreach (DataRow datarow in dtBotConfig.Rows)
            {
                BotClass bot = new BotClass(0, datarow[0].ToString(), datarow[1].ToString());
                OutputText(String.Format(">Testing {0} .......", bot.Name));

                if (HTTPUtility.GetMove(bot) != "failed")
                {
                    OutputText("test passed.\n");
                    datarow[3] = "Ok";
                }
                else
                {
                    datarow[2] = false;
                    datarow[3] = "Error";
                    OutputText(String.Format("{0} test failed:  Exception {1} \n", bot.Name, "failed to receive"));
                }
            }
        }
        public void SendEmail(string webUrl, int notOvertimeItemId, string emailKey, string approverName)
        {
            Thread thread = new Thread(delegate ()
            {
                var _emailTemplateDAL = new EmailTemplateDAL(webUrl);
                var _employeeDAL = new EmployeeInfoDAL(webUrl);
                var _shiftTimeDAL = new ShiftTimeDAL(webUrl);
                var _sendMailActivity = new SendEmailActivity();
                var notOvertimeRequestMailItem = _emailTemplateDAL.GetByKey(emailKey);
                var notOvertimeManagementItem = _notOvertimeManagementDAL.GetByID(notOvertimeItemId);

                if (notOvertimeRequestMailItem != null && notOvertimeManagementItem != null)
                {
                    var employee = _employeeDAL.GetByID(notOvertimeManagementItem.Requester.LookupId);

                    if (employee != null && !string.IsNullOrEmpty(employee.Email))
                    {
                        string emailBody = HTTPUtility.HtmlDecode(notOvertimeRequestMailItem.MailBody);

                        //lookup email
                        string link = $"{webUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceMember}";
                        if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.Administrator)
                        {
                            link = $"{webUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceAdmin}";
                        }
                        if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.DepartmentHead)
                        {
                            link = $"{webUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceManager}";
                        }
                        emailBody = string.Format(emailBody, employee.FullName, notOvertimeManagementItem.Requester.LookupValue,
                            notOvertimeManagementItem.Date.ToString(StringConstant.DateFormatddMMyyyy2),
                            notOvertimeManagementItem.Reason, notOvertimeManagementItem.Comment, approverName);
                        emailBody = emailBody.Replace("#link", link);
                        _sendMailActivity.SendMail(webUrl, notOvertimeRequestMailItem.MailSubject, employee.Email, true, false, emailBody);
                    }
                }
            });

            thread.IsBackground = true;
            thread.Start();
        }
Esempio n. 26
0
            private void ServerRegistration()
            {
                var task = new Task(() => {
                    ;
                    //toolStripStatusLabel1.Text = $"{Resources.Main_ServerRegistration}...";
                    string url =
                        $"http://getlist2.obovse.ru/remote/index.php?v={Assembly.GetExecutingAssembly().GetName().Version}&do=list&localip={ip}:{port}&proxy=false";
                    string result = HTTPUtility.GetRequest(url);
                    Log.LogInformation(result);
                    //if (result.Split('|')[0] == "new_version") {
                    //    if (mcbCheckUpdate.Checked) {
                    //        MenuItemNewVersion.Text = result.Split('|')[1];
                    //        MenuItemNewVersion.Visible = true;
                    //        urlnewversion = result.Split('|')[2];
                    //        newversion = result.Split('|')[3];
                    //    }
                    //}
                    //timerR.Enabled = mcbUseProxy.Checked;
                    //toolStripStatusLabel1.Text = $"{Resources.Main_ServerRegistration}: OK";
                    //Log.Debug("StartServer->Result: {0}", result);
                });

                task.Start();
            }
Esempio n. 27
0
        public async Task <Stream> GetStream()
        {
            MemoryStream iconData = null;

            try {
                byte[] buffer;

                if (!IsLocalFile)
                {
                    buffer = await HTTPUtility.GetBytesRequestAsync(_imageLink);

                    await File.WriteAllBytesAsync(LocalFilePath, buffer);
                }
                else
                {
                    buffer = await File.ReadAllBytesAsync(LocalFilePath);
                }

                iconData = new MemoryStream(buffer);
            } catch (Exception exception) {
            }

            return(iconData);
        }
Esempio n. 28
0
        public async Task <string> GetFileList(Dictionary <string, string> files, string key, string type)
        {
            var items = new List <IItem>();

            if (files.Count > 0)
            {
                if (files.Count > 1)
                {
                    string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, type, key);
                    return(await HTTPUtility.GetRequestAsync(stream));
                }
                else
                {
                    string stream = string.Format("{0}/ace/getstream?{1}={2}", AceStreamEngine.GetServer, type, key);
                    string name   = Path.GetFileName(files.First().Value);
                    var    item   = new FileItem()
                    {
                        Title     = Path.GetFileName(name),
                        ImageLink = "http://obovse.ru/ForkPlayer2.5/img/file.png",
                        Link      = stream
                    };
                    items.Add(item);

                    stream = string.Format("{0}/ace/manifest.m3u8?{1}={2}", AceStreamEngine.GetServer, type, key);
                    item   = new FileItem()
                    {
                        Title     = "(hls) " + Path.GetFileName(name),
                        ImageLink = "http://obovse.ru/ForkPlayer2.5/img/file.png",
                        Link      = stream
                    };
                    items.Add(item);
                }
            }

            return(ResponseManager.CreateResponse(items));
        }
        public override byte[] Handle(HttpRequest request, HttpResponse response)
        {
            try {
                string url = HttpUtility.UrlDecode(request.Path.Value.Replace("/" + UrlPath, ""));
                if (url.StartsWith("B"))
                {
                    if (url.Contains("endbase64"))
                    {
                        url = Encoding.UTF8.GetString(
                            Convert.FromBase64String(url.Substring(1, url.IndexOf("endbase64") - 1))) +
                              url.Substring(url.IndexOf("endbase64") + 9);
                    }
                    else
                    {
                        url = Encoding.UTF8.GetString(Convert.FromBase64String(url.Substring(1, url.Length - 2)));
                    }
                }
                string ts       = string.Empty;
                bool   usertype = false;
                var    header   = new Dictionary <string, string>();
                Log.LogDebug("Proxy url: " + url);
                if (url.Contains("OPT:"))
                {
                    if (url.IndexOf("OPEND:/") == url.Length - 7)
                    {
                        url = url.Replace("OPEND:/", "");
                        Log.LogDebug("Req root m3u8 " + url);
                    }
                    else
                    {
                        ts = url.Substring(url.IndexOf("OPEND:/") + 7);
                        Log.LogDebug("Req m3u8 ts " + ts);
                    }
                    if (url.Contains("OPEND:/"))
                    {
                        url = url.Substring(0, url.IndexOf("OPEND:/"));
                    }
                    var headers = url.Substring(url.IndexOf("OPT:") + 4).Replace("--", "|").Split('|');
                    url = url.Remove(url.IndexOf("OPT:"));
                    for (int i = 0; i < headers.Length; i++)
                    {
                        if (headers[i] == "ContentType")
                        {
                            if (request.Headers.ContainsKey("Range"))
                            {
                                header["Range"] = request.Headers["Range"];
                            }
                            response.Headers.Add("Accept-Ranges", "bytes");

                            Log.LogDebug("reproxy with ContentType");

                            usertype             = true;
                            response.ContentType = headers[++i];
                            continue;
                        }
                        header[headers[i]] = headers[++i];

                        Log.LogDebug($"{headers[i - 1]}={headers[i]}");
                    }
                }
                if (!usertype)
                {
                    if (!string.IsNullOrEmpty(ts))
                    {
                        url = url.Remove(url.LastIndexOf("/") + 1) + ts;

                        Log.LogDebug($"Full ts url {url}");

                        response.ContentType = "video/mp2t";
                    }
                    else
                    {
                        response.ContentType = "application/vnd.apple.mpegurl";
                    }
                }
                //response.Headers.Remove("Tranfer-Encoding");
                //response.Headers.Remove("Keep-Alive");
                response.Headers.Add("Connection", "Close");

                // response.AddHeader("Accept-Ranges", "bytes");
                Log.LogDebug($"Real url:{url}");
                Log.LogDebug($"usertype:{usertype}");
                var data = HTTPUtility.GetBytesRequest(url, header, usertype);
                return(data);
            } catch (Exception exception) {
                Log.LogError(exception);
                return(Encoding.UTF8.GetBytes(exception.ToString()));
            }
        }
Esempio n. 30
0
        public override async Task <string> Handle(HttpRequest request, HttpResponse response)
        {
            string result = string.Empty;

            Log.LogDebug(request.Host.ToUriComponent());
            var requestStrings = HttpUtility.UrlDecode(request.QueryString.Value)?.Substring(1).Split('|');

            if (request.Method == "POST")
            {
                var    getPostParam = new StreamReader(request.Body, true);
                string postData     = getPostParam.ReadToEnd();
                requestStrings = HttpUtility.UrlDecode(postData).Substring(2).Split('|');
            }

            if (requestStrings != null)
            {
                Log.LogDebug("Parsing: {0}", requestStrings[0]);

                string curlResponse = requestStrings[0].StartsWith("curl")
                    ? await CurlRequest(requestStrings[0])
                    : await HTTPUtility.GetRequestAsync(requestStrings[0]);

                if (requestStrings.Length == 1)
                {
                    result = curlResponse;
                }
                else
                {
                    if (!requestStrings[1].Contains(".*?"))
                    {
                        if (string.IsNullOrEmpty(requestStrings[1]) && string.IsNullOrEmpty(requestStrings[2]))
                        {
                            result = curlResponse;
                        }
                        else
                        {
                            int num1 = curlResponse.IndexOf(requestStrings[1], StringComparison.Ordinal);
                            if (num1 == -1)
                            {
                                result = string.Empty;
                            }
                            else
                            {
                                num1 += requestStrings[1].Length;
                                int num2 = curlResponse.IndexOf(requestStrings[2], num1, StringComparison.Ordinal);
                                result = num2 == -1 ? string.Empty : curlResponse.Substring(num1, num2 - num1);
                            }
                        }
                    }
                    else
                    {
                        Log.LogDebug("ParseLinkRequest: {0}", requestStrings[1] + "(.*?)" + requestStrings[2]);

                        string pattern = requestStrings[1] + "(.*?)" + requestStrings[2];
                        var    regex   = new Regex(pattern, RegexOptions.Multiline);
                        var    match   = regex.Match(curlResponse);
                        if (match.Success)
                        {
                            result = match.Groups[1].Captures[0].ToString();
                        }
                    }
                }
            }

            return(result);
        }