Esempio n. 1
0
    public static string DeleteAttachment(int newsAttachmentId)
    {
        Dictionary <string, string> result = new Dictionary <string, string>()
        {
            { "deleted", "" }, { "id", "" }, { "error", "" }
        };

        bool   deleted = false;
        string errorMsg = string.Empty, ids = string.Empty;

        try
        {
            deleted = WTSNews.DeleteNewsAttachment(newsAttachmentId: newsAttachmentId);
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);
            errorMsg += ": " + ex.Message;
            deleted   = false;
        }

        result["deleted"] = "true";
        //result["id"] = id.ToString();
        //result["error"] = errorMsg;

        return(JsonConvert.SerializeObject(result, Formatting.None));
    }
Esempio n. 2
0
    public static string ReadArticle(string newsId = "")
    {
        Dictionary <string, string> result = new Dictionary <string, string>();

        long newsArticleId = 0, userNewsId = 0;

        long.TryParse(newsId, out newsArticleId);

        bool   saved    = false;
        string errorMsg = string.Empty;

        try
        {
            //save the user_news record
            saved = WTSNews.MarkArticleRead(newsArticleId);
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);
            saved     = false;
            errorMsg += Environment.NewLine + ex.Message;
        }

        result.Add("saved", saved.ToString());
        result.Add("error", errorMsg);
        result.Add("id", userNewsId.ToString());

        return(JsonConvert.SerializeObject(result, Formatting.None));
    }
Esempio n. 3
0
    protected void LoadSystemNofitication()
    {
        DataTable dt = new DataTable();

        dt = WTSNews.GetNews(newsId: 0, sysNotification: 1);

        if (dt != null && dt.Rows.Count > 0)
        {
            StringBuilder summarytable = new StringBuilder();
            summarytable.AppendFormat("<table cellspacing='0' cellpadding='0' width='98%'>");
            summarytable.AppendFormat("<tr class='gridHeader'><td style='padding-right: 10px'>Date(s)</td><td>Title</td></tr>");

            foreach (DataRow dr in dt.Rows)
            {
                summarytable.AppendFormat("<tr class='gridBody' style='cursor:pointer'>");
                for (int x = 0; x <= dt.Columns.Count - 1; x++)
                {
                    //'value field
                    summarytable.AppendFormat("<td style='color:black'>");

                    summarytable.AppendFormat(dr[x].ToString());
                    summarytable.AppendFormat("</td>");
                }

                summarytable.AppendFormat("</tr>");
            }

            summarytable.AppendFormat("</table>");
            divSystemNoteInfo.InnerHtml = summarytable.ToString();

            showSysNotification = true;
        }
    }
Esempio n. 4
0
    public static string DeleteNews(string newsId)
    {
        string result    = "";
        bool   deleted   = false;
        int    intNewsId = -1;

        int.TryParse(newsId, out intNewsId);

        deleted = WTSNews.DeleteNews(intNewsId);
        result  = deleted.ToString();

        return(JsonConvert.SerializeObject(result, Newtonsoft.Json.Formatting.None));
    }
Esempio n. 5
0
    private void loadAttachments()
    {
        DataTable dt = WTSNews.News_GetAttachmentList(newsID: this._newsID, showArchived: 0);

        if (dt != null)
        {
            dc = dt.Columns;

            if (dt.Rows.Count > 0)
            {
                //spanRowCount.InnerText = dt.Rows.Count.ToString();
                gridAttachments.DataSource = dt;
                gridAttachments.DataBind();
            }
        }
    }
Esempio n. 6
0
    protected void LoadNewsItems()
    {
        DataTable dtNewsOverview = null;

        dtNewsOverview = WTSNews.GetNews();
        HttpContext.Current.Session["dtNewsOverview"] = dtNewsOverview;
        Page.ClientScript.RegisterArrayDeclaration("DCC", JsonConvert.SerializeObject(DCC, Newtonsoft.Json.Formatting.None));
        InitializeColumnData(ref dtNewsOverview);
        dtNewsOverview.AcceptChanges();

        if (dtNewsOverview != null)
        {
            DCC = dtNewsOverview.Columns;
        }

        gridNewsOverview.DataSource = (DataTable)Session["dtNewsOverview"];
        gridNewsOverview.DataBind();
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ReadQueryString();
        InitializeEvents();
        InitializeControls();

        //If _newsID != -1 then we are editing a news entry
        if (_newsID != -1)
        {
            //Gather Datatable with NewsID
            DataTable dt = new DataTable();
            dt = WTSNews.GetNews(newsId: _newsID);

            if (dt.Rows.Count > 0)
            {
                Dictionary <string, object> SeverAttributes = new Dictionary <string, object>();
                //Set Control Values
                //SeverAttributes.Add("txtArticleTitle", HttpUtility.UrlDecodeToBytes(dt.Rows[1]["Summary"].ToString()));
                SeverAttributes.Add("txtArticleTitle", Server.HtmlEncode(dt.Rows[1]["Summary"].ToString()));
                SeverAttributes.Add("textNewsBody", Server.HtmlEncode(dt.Rows[1]["Detail"].ToString()));
                // SeverAttributes.Add("textNewsBody1", HttpUtility.UrlEncodeToBytes(dt.Rows[1]["Detail"].ToString()));
                //SeverAttributes.Add("textNewsBody2", Server.HtmlEncode(dt.Rows[1]["Detail"].ToString()));
                //SeverAttributes.Add("textNewsBody3", Server.UrlEncode(dt.Rows[1]["Detail"].ToString()));


                //SeverAttributes.Add("fileUpload", Server.HtmlEncode(dt.Rows[1]["FileName"].ToString()));
                SeverAttributes.Add("ddlNotificationType", dt.Rows[1]["NewsType"].ToString());
                SeverAttributes.Add("txtDateStart", dt.Rows[1]["Start_Date"].ToString());
                SeverAttributes.Add("txtDateEnd", dt.Rows[1]["End_Date"].ToString());
                if (dt.Rows[1]["Bln_Active"].ToString() == "1")
                {
                    SeverAttributes.Add("Bln_Active", "true");
                }
                else
                {
                    SeverAttributes.Add("Bln_Active", "false");
                }
                JsonSeverAttributes = JsonConvert.SerializeObject(SeverAttributes);
            }
            //loadAttachments();
        }
    }
Esempio n. 8
0
    protected void btnSubmit_Click(Object sender, EventArgs e)
    {
        bool   exists                = false;
        int    newAttachmentID       = 0;
        int    newModuleAttachmentID = 0;
        bool   saved    = false;
        string errorMsg = string.Empty;

        var dtfilesAttr = JsonConvert.DeserializeObject <DataTable>(inpHide.Value);

        if (this.Edit || (this.fileUpload1.HasFile))
        {
            if (!this.Edit)                  //adding an attachment, not editing one
            {
                int i = 0;
                foreach (HttpPostedFile uploadedFile in fileUpload1.PostedFiles)
                {
                    string   fileName       = "";
                    string   fileExtension  = "";
                    string   strFileTypeID  = "";
                    string   strDescription = "";
                    int      intAttachType  = 0;
                    Stream   fStream        = uploadedFile.InputStream;
                    int      fileLength     = uploadedFile.ContentLength;
                    byte[]   fByte          = new byte[fileLength];
                    string   fileType       = uploadedFile.ContentType;
                    string[] splitFileName  = fileName.Split('\\');
                    fileName = splitFileName[splitFileName.Length - 1];

                    fStream.Read(fByte, 0, fByte.Length);
                    fStream.Close();

                    if (fileUpload1.PostedFiles.Count > 1)
                    {
                        fileName      = dtfilesAttr.Rows[i]["name"].ToString();
                        strFileTypeID = dtfilesAttr.Rows[i]["type"].ToString();
                        int.TryParse(strFileTypeID, out intAttachType);
                        strDescription = dtfilesAttr.Rows[i]["description"].ToString();
                    }
                    else
                    {
                        fileName      = uploadedFile.FileName;
                        strFileTypeID = ddlAttachmentType.SelectedValue;
                        int.TryParse(ddlAttachmentType.SelectedValue, out intAttachType);
                        strDescription = txtDescription.Text;
                    }

                    splitFileName = fileName.Split('\\');
                    fileName      = splitFileName[splitFileName.Length - 1];
                    splitFileName = fileName.Split('.');
                    fileExtension = splitFileName[splitFileName.Length - 1];

                    switch (Module.ToUpper())
                    {
                    case "TASK":
                        saved = WorkItem_Task.Attachment_Add(WorkItemTaskID: this.workItemTaskID
                                                             , attachmentTypeID: intAttachType
                                                             , fileName: fileName
                                                             , title: strDescription
                                                             , description: strDescription
                                                             , fileData: fByte
                                                             , extensionID: 0
                                                             , newAttachmentID: out newAttachmentID
                                                             , newWorkItemAttachmentID: out newModuleAttachmentID
                                                             , errorMsg: out errorMsg);
                        break;

                    case "WORKITEM":
                        saved = WorkloadItem.Attachment_Add(workItemID: this.WorkItemID
                                                            , attachmentTypeID: intAttachType
                                                            , fileName: fileName
                                                            , title: strDescription
                                                            , description: strDescription
                                                            , fileData: fByte
                                                            , extensionID: 0
                                                            , newAttachmentID: out newAttachmentID
                                                            , newWorkItemAttachmentID: out newModuleAttachmentID
                                                            , errorMsg: out errorMsg);
                        break;

                    case "WORKREQUEST":
                        saved = WorkRequest.Attachment_Add(workRequestID: this.WorkRequestID
                                                           , attachmentTypeID: intAttachType
                                                           , fileName: fileName
                                                           , title: strDescription
                                                           , description: strDescription
                                                           , fileData: fByte
                                                           , extensionID: 0
                                                           , newAttachmentID: out newAttachmentID
                                                           , newWorkItemAttachmentID: out newModuleAttachmentID
                                                           , errorMsg: out errorMsg);
                        break;

                    case "MEETING":
                        saved = AOR.AORMeetingInstanceAttachment_Save(0, AORMeetingInstanceID, 0, intAttachType, fileName, strDescription, strDescription, fByte, out newAttachmentID);
                        break;

                    case "RQMTDESC":
                        saved = RQMT.RQMTDescriptionAttachment_Save(0, RQMTDescriptionID, 0, intAttachType, fileName, strDescription, fByte, out newAttachmentID);
                        break;

                    case "MDIMAGE":
                        Dictionary <string, string> result = new Dictionary <string, string> {
                            { "saved", "false" }, { "exists", "false" }, { "newID", "0" }, { "error", "" }
                        };
                        string[] allowedExtensions = new string[] { ".jpg", ".jpeg", ".png", ".gif" };
                        string   extension         = Path.GetExtension(fileName).ToLower();

                        if (!allowedExtensions.Contains(extension))
                        {
                            continue;
                        }

                        result   = MasterData.Image_Add(ImageName: strDescription, Description: strDescription, FileName: fileName, FileData: fByte);
                        saved    = result["saved"].ToUpper() == "TRUE";
                        errorMsg = result["error"];
                        break;

                    case "NEWS":
                        saved = WTSNews.NewsAttachment_Add(newsID: this.NewsID
                                                           , attachmentTypeID: (int)AttachmentTypeEnum.News
                                                           , fileName: fileName
                                                           , title: strDescription
                                                           , description: strDescription
                                                           , fileData: fByte
                                                           , extensionID: 0
                                                           , newAttachmentID: out newAttachmentID
                                                           //, newWorkItemAttachmentID: out newModuleAttachmentID
                                                           , errorMsg: out errorMsg);
                        break;

                    default:
                        saved = WTSData.Attachment_Add(attachmentTypeID: intAttachType
                                                       , fileName: fileName
                                                       , title: strDescription
                                                       , description: strDescription
                                                       , fileData: fByte
                                                       , extensionID: 0
                                                       , newID: out newAttachmentID
                                                       , errorMsg: out errorMsg);
                        break;
                    }

                    i += 1;
                }
            }
            else
            {
                string fileName = "";
                fileName = fileUpload1.FileName;

                //Stream fStream = fileUpload1.PostedFile.InputStream;
                //int fileLength = fileUpload1.PostedFile.ContentLength;

                //byte[] fByte = new byte[fileLength];

                string fileType = string.Empty;
                if (fileUpload1.PostedFile != null)
                {
                    fileName = fileUpload1.PostedFile.FileName;
                    fileType = fileUpload1.PostedFile.ContentType;
                }
                string[] splitFileName = fileName.Split('\\');
                fileName      = splitFileName[splitFileName.Length - 1];
                splitFileName = fileName.Split('.');

                string fileExtension = splitFileName[splitFileName.Length - 1];
                //fStream.Read(fByte, 0, fByte.Length);
                //fStream.Close();

                if (fileName == "")
                {
                    fileName = this.OriginalFileName;
                }

                string attachmentType = ddlAttachmentType.SelectedValue;
                if (Module == "News")
                {
                    attachmentType = ((int)AttachmentTypeEnum.News).ToString();
                }

                saved = WTSData.Attachment_Update(attachmentID: this.AttachmentID
                                                  , attachmentTypeID: int.Parse(attachmentType)
                                                  , fileName: fileName
                                                  , title: txtDescription.Text
                                                  , description: txtDescription.Text
                                                  //, fileData: fByte
                                                  , exists: out exists
                                                  , errorMsg: out errorMsg);
            }

            if (!saved || errorMsg.Length > 0)
            {
                lblError.Text = errorMsg;
            }
            else
            {
                if (!exists)
                {
                    HasUploaded = 1;
                }
                else
                {
                    AlreadyExists = 1;
                }

                if (Module.ToUpper() == "WORKITEM")
                {
                    Workload.SendWorkloadEmail("WorkItem", false, this.WorkItemID);
                }
            }
        }
    }
Esempio n. 9
0
    protected void btnSubmit_Click(Object sender, EventArgs e)
    {
        Dictionary <string, string> result = new Dictionary <string, string> {
            { "saved", "false" }, { "exists", "false" }, { "newID", "0" }, { "error", "" }
        };
        bool   saved           = false;//, result = false;
        int    newAttachmentID = 0;
        string errorMsg        = "";

        Dictionary <string, object> attributeList = new Dictionary <string, object>();

        attributeList.Add("NotificationType", 1);
        attributeList.Add("StartDate", txtDateStart.Text);
        attributeList.Add("EndDate", txtDateEnd.Text);
        attributeList.Add("Active", cbActive.Checked.ToString());

        //if (_newsTypeID == (int)NewsTypeEnum.NewsArticle)
        //{
        attributeList.Add("ArticleTitle", Server.UrlDecode(txtArticleTitle.Text));
        attributeList.Add("Description", Server.UrlDecode(textNewsBody.Value));
        //attributeList.Add("Description", "");
        //}
        //else
        //{
        //    //The newsOverviews have an autogenerated Description & Title
        //    attributeList.Add("ArticleTitle", "Weekly Overview");
        //    attributeList.Add("Description", "Weekly Overview For: " + txtDateStart.Text + " TO " + txtDateEnd.Text);
        //}

        try
        {
            WTSNewsArticle item = new WTSNewsArticle(attributeList);
            item.Description = Server.HtmlDecode(item.Description);

            int newsTypeID = 0;
            int.TryParse(ddlNotificationType.SelectedValue, out newsTypeID);

            result = WTSNews.SaveNews(item, _newsID, newsTypeID);

            if (result["saved"] == "True")
            {
                int news_ID = 0;
                int.TryParse(result["newID"], out news_ID);

                int attachment_ID = 0;
                int.TryParse(result["attachmentID"], out attachment_ID);


                if (news_ID != 0 && attachment_ID == 0) //Adding new Attachment
                {
                    //if (fileUpload.HasFiles)
                    //{
                    //    foreach (var file in fileUpload.PostedFiles)
                    //    {
                    //        Stream fileStream = file.InputStream;
                    //        byte[] fileData = new byte[file.ContentLength];
                    //        string fileName = file.FileName;
                    //        string[] splitFileName = fileName.Split('\\');

                    //        fileName = splitFileName[splitFileName.Length - 1];

                    //        fileStream.Read(fileData, 0, fileData.Length);
                    //        fileStream.Close();

                    //        result["saved"] = WTSNews.NewsAttachment_Add(newsID: news_ID, attachmentTypeID: (int)AttachmentTypeEnum.News, fileName: fileName, title: item.ArticleTitle, description: item.Description, fileData: fileData, extensionID: 0, newAttachmentID: out newAttachmentID, errorMsg: out errorMsg).ToString();

                    //    }
                    //}
                }
                else if (news_ID != 0 && attachment_ID != 0) //Updating old Attachment
                {
                }
            }
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);

            result["error"] = ex.Message;
        }

        ScriptManager.RegisterStartupScript(this, this.GetType(), "complete", "<script type=\"text/javascript\">complete('" + "" + "');</script>", false);
    }